From a5f83ccdd9672c7d42977ab76dc0cc57d967eb8d Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 13 Dec 2010 12:21:26 +0000 Subject: [PATCH] EnableMigration config setting implemented --- Builder/IISMainHandler/build.txt | 2 +- Common/Config.cs | 3 +++ IISMainHandler/handlers/request/LoginHandler.cs | 12 +++++++----- .../handlers/request/RegisterByInviteHandler.cs | 13 ++++++++----- IISMainHandler/handlers/request/RegisterHandler.cs | 12 +++++++----- IISMainHandler/handlers/request/SendPMHandler.cs | 3 ++- IISMainHandler/handlers/response/LoginHandler.cs | 1 + .../handlers/response/MigrateAccountHandler.cs | 1 + templates/Modern/Login.xslt | 2 ++ 9 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index d9bc155..a1b04e2 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1812 \ No newline at end of file +1814 \ No newline at end of file diff --git a/Common/Config.cs b/Common/Config.cs index d3b85bc..59eefb9 100644 --- a/Common/Config.cs +++ b/Common/Config.cs @@ -31,6 +31,8 @@ namespace FLocal.Common { public readonly bool IsIndexingDisabled; + public readonly bool IsMigrationEnabled; + protected Config(NameValueCollection data) : base(data) { this.InitTime = DateTime.Now.ToLongTimeString(); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); @@ -43,6 +45,7 @@ namespace FLocal.Common { this.AdminUserName = data["AdminUserName"]; this.ActivityThreshold = TimeSpan.FromMinutes(int.Parse(data["ActivityThreshold"])); this.IsIndexingDisabled = parseBool(data["DisableIndexing"]); + this.IsMigrationEnabled = parseBool(data["EnableMigration"]); } public static void Init(NameValueCollection data) { diff --git a/IISMainHandler/handlers/request/LoginHandler.cs b/IISMainHandler/handlers/request/LoginHandler.cs index 4f10c49..112edb1 100644 --- a/IISMainHandler/handlers/request/LoginHandler.cs +++ b/IISMainHandler/handlers/request/LoginHandler.cs @@ -30,12 +30,14 @@ namespace FLocal.IISHandler.handlers.request { protected override XElement[] Do(WebContext context) { - try { - Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]); - if(tmpAccount.needsMigration) { - throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["name"]); + if(Config.instance.IsMigrationEnabled) { + try { + Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]); + if(tmpAccount.needsMigration) { + throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["name"]); + } + } catch(NotFoundInDBException) { } - } catch(NotFoundInDBException) { } Account account = Account.tryAuthorize(context.httprequest.Form["name"], context.httprequest.Form["password"]); diff --git a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs b/IISMainHandler/handlers/request/RegisterByInviteHandler.cs index 9ea29b8..10cb215 100644 --- a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs +++ b/IISMainHandler/handlers/request/RegisterByInviteHandler.cs @@ -14,12 +14,15 @@ 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("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]); + + if(Config.instance.IsMigrationEnabled) { + try { + Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]); + if(tmpAccount.needsMigration) { + throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]); + } + } catch(NotFoundInDBException) { } - } catch(NotFoundInDBException) { } Invite invite = Invite.LoadById(int.Parse(context.httprequest.Form["inviteId"])); diff --git a/IISMainHandler/handlers/request/RegisterHandler.cs b/IISMainHandler/handlers/request/RegisterHandler.cs index 7385072..6176e4c 100644 --- a/IISMainHandler/handlers/request/RegisterHandler.cs +++ b/IISMainHandler/handlers/request/RegisterHandler.cs @@ -14,12 +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("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]); + if(Config.instance.IsMigrationEnabled) { + try { + Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]); + if(tmpAccount.needsMigration) { + throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]); + } + } catch(NotFoundInDBException) { } - } catch(NotFoundInDBException) { } if(!LocalNetwork.IsLocalNetwork(context.remoteHost)) throw new FLocalException("IP '" + context.remoteHost.ToString() + "' is not allowed"); diff --git a/IISMainHandler/handlers/request/SendPMHandler.cs b/IISMainHandler/handlers/request/SendPMHandler.cs index 4cb8a65..972a234 100644 --- a/IISMainHandler/handlers/request/SendPMHandler.cs +++ b/IISMainHandler/handlers/request/SendPMHandler.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; +using FLocal.Common; using FLocal.Common.dataobjects; namespace FLocal.IISHandler.handlers.request { @@ -25,7 +26,7 @@ namespace FLocal.IISHandler.handlers.request { throw new ApplicationException("receiverId/receiverName not passed"); } - if(receiver.needsMigration) throw new ApplicationException("User is not migrated"); + if(Config.instance.IsMigrationEnabled && receiver.needsMigration) throw new ApplicationException("User is not migrated"); PMMessage newMessage = PMConversation.SendPMMessage( context.account, diff --git a/IISMainHandler/handlers/response/LoginHandler.cs b/IISMainHandler/handlers/response/LoginHandler.cs index a2e2e07..3d612aa 100644 --- a/IISMainHandler/handlers/response/LoginHandler.cs +++ b/IISMainHandler/handlers/response/LoginHandler.cs @@ -20,6 +20,7 @@ namespace FLocal.IISHandler.handlers.response { return new XElement[] { new XElement("isLocalNetwork", LocalNetwork.IsLocalNetwork(context.remoteHost).ToPlainString()), new XElement("ip", context.remoteHost.ToString()), + new XElement("isMigrationEnabled", Config.instance.IsMigrationEnabled.ToPlainString()), }; } diff --git a/IISMainHandler/handlers/response/MigrateAccountHandler.cs b/IISMainHandler/handlers/response/MigrateAccountHandler.cs index d9daf33..7164f6c 100644 --- a/IISMainHandler/handlers/response/MigrateAccountHandler.cs +++ b/IISMainHandler/handlers/response/MigrateAccountHandler.cs @@ -17,6 +17,7 @@ namespace FLocal.IISHandler.handlers.response { } protected override IEnumerable getSpecificData(WebContext context) { + if(!Config.instance.IsMigrationEnabled) throw new FLocalException("Migration is disabled"); string username; if(context.httprequest.Form["username"] != null && context.httprequest.Form["username"] != "") { username = context.httprequest.Form["username"]; diff --git a/templates/Modern/Login.xslt b/templates/Modern/Login.xslt index aa62bc5..f6704fb 100644 --- a/templates/Modern/Login.xslt +++ b/templates/Modern/Login.xslt @@ -36,6 +36,7 @@
+
@@ -64,6 +65,7 @@

+