From bb1483b3c7379e47b4e11b34ae3d1855ec878c09 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Fri, 27 Aug 2010 17:45:32 +0000 Subject: [PATCH] Registration -> Migration redirect --- Builder/IISMainHandler/build.txt | 2 +- .../handlers/request/RegisterByInviteHandler.cs | 8 ++++++++ IISMainHandler/handlers/request/RegisterHandler.cs | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 930e0e0..1c8a8a8 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -930 \ No newline at end of file +932 \ No newline at end of file diff --git a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs b/IISMainHandler/handlers/request/RegisterByInviteHandler.cs index 5ea8638..993f794 100644 --- a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs +++ b/IISMainHandler/handlers/request/RegisterByInviteHandler.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"); diff --git a/IISMainHandler/handlers/request/RegisterHandler.cs b/IISMainHandler/handlers/request/RegisterHandler.cs index 00295b0..696c824 100644 --- a/IISMainHandler/handlers/request/RegisterHandler.cs +++ b/IISMainHandler/handlers/request/RegisterHandler.cs @@ -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"]);