Registration -> Migration redirect

main
Inga 🏳‍🌈 15 years ago
parent aa2a9a51e4
commit bb1483b3c7
  1. 2
      Builder/IISMainHandler/build.txt
  2. 8
      IISMainHandler/handlers/request/RegisterByInviteHandler.cs
  3. 8
      IISMainHandler/handlers/request/RegisterHandler.cs

@ -14,6 +14,14 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterByInviteHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
if(tmpAccount.needsMigration) {
throw new RedirectException("/MigrateAccount/" + context.httprequest.Form["login"]);
}
} catch(NotFoundInDBException) {
}
Invite invite = Invite.LoadById(int.Parse(context.httprequest.Form["inviteId"]));
if(invite.isUsed) throw new FLocalException("Invite is already used");
if(context.httprequest.Form["password"] != context.httprequest.Form["password2"]) throw new FLocalException("Passwords mismatch");

@ -14,6 +14,14 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
if(tmpAccount.needsMigration) {
throw new RedirectException("/MigrateAccount/" + context.httprequest.Form["login"]);
}
} catch(NotFoundInDBException) {
}
if(!LocalNetwork.IsLocalNetwork(context.remoteHost)) throw new FLocalException("IP '" + context.remoteHost.ToString() + "' is not allowed");
if(context.httprequest.Form["password"] != context.httprequest.Form["password2"]) throw new FLocalException("Passwords mismatch");
return Account.createAccount(context.httprequest.Form["login"], context.httprequest.Form["password"], context.httprequest.UserHostAddress, context.httprequest.Form["registrationEmail"]);

Loading…
Cancel
Save