EnableMigration config setting implemented

main
Inga 🏳‍🌈 14 years ago
parent 29df0e492b
commit a5f83ccdd9
  1. 2
      Builder/IISMainHandler/build.txt
  2. 3
      Common/Config.cs
  3. 12
      IISMainHandler/handlers/request/LoginHandler.cs
  4. 13
      IISMainHandler/handlers/request/RegisterByInviteHandler.cs
  5. 12
      IISMainHandler/handlers/request/RegisterHandler.cs
  6. 3
      IISMainHandler/handlers/request/SendPMHandler.cs
  7. 1
      IISMainHandler/handlers/response/LoginHandler.cs
  8. 1
      IISMainHandler/handlers/response/MigrateAccountHandler.cs
  9. 2
      templates/Modern/Login.xslt

@ -31,6 +31,8 @@ namespace FLocal.Common {
public readonly bool IsIndexingDisabled; public readonly bool IsIndexingDisabled;
public readonly bool IsMigrationEnabled;
protected Config(NameValueCollection data) : base(data) { protected Config(NameValueCollection data) : base(data) {
this.InitTime = DateTime.Now.ToLongTimeString(); this.InitTime = DateTime.Now.ToLongTimeString();
this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance);
@ -43,6 +45,7 @@ namespace FLocal.Common {
this.AdminUserName = data["AdminUserName"]; this.AdminUserName = data["AdminUserName"];
this.ActivityThreshold = TimeSpan.FromMinutes(int.Parse(data["ActivityThreshold"])); this.ActivityThreshold = TimeSpan.FromMinutes(int.Parse(data["ActivityThreshold"]));
this.IsIndexingDisabled = parseBool(data["DisableIndexing"]); this.IsIndexingDisabled = parseBool(data["DisableIndexing"]);
this.IsMigrationEnabled = parseBool(data["EnableMigration"]);
} }
public static void Init(NameValueCollection data) { public static void Init(NameValueCollection data) {

@ -30,12 +30,14 @@ namespace FLocal.IISHandler.handlers.request {
protected override XElement[] Do(WebContext context) { protected override XElement[] Do(WebContext context) {
try { if(Config.instance.IsMigrationEnabled) {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]); try {
if(tmpAccount.needsMigration) { Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]);
throw new RedirectException("/My/Login/MigrateAccount/" + 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"]); Account account = Account.tryAuthorize(context.httprequest.Form["name"], context.httprequest.Form["password"]);

@ -14,12 +14,15 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterByInviteHandler : AbstractNewAccountHandler { class RegisterByInviteHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) { protected override Account DoCreateAccount(WebContext context) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]); if(Config.instance.IsMigrationEnabled) {
if(tmpAccount.needsMigration) { try {
throw new RedirectException("/My/Login/MigrateAccount/" + context.httprequest.Form["login"]); 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"])); Invite invite = Invite.LoadById(int.Parse(context.httprequest.Form["inviteId"]));

@ -14,12 +14,14 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterHandler : AbstractNewAccountHandler { class RegisterHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) { protected override Account DoCreateAccount(WebContext context) {
try { if(Config.instance.IsMigrationEnabled) {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]); try {
if(tmpAccount.needsMigration) { Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
throw new RedirectException("/My/Login/MigrateAccount/" + 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"); if(!LocalNetwork.IsLocalNetwork(context.remoteHost)) throw new FLocalException("IP '" + context.remoteHost.ToString() + "' is not allowed");

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using FLocal.Common;
using FLocal.Common.dataobjects; using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.request { namespace FLocal.IISHandler.handlers.request {
@ -25,7 +26,7 @@ namespace FLocal.IISHandler.handlers.request {
throw new ApplicationException("receiverId/receiverName not passed"); 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( PMMessage newMessage = PMConversation.SendPMMessage(
context.account, context.account,

@ -20,6 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
return new XElement[] { return new XElement[] {
new XElement("isLocalNetwork", LocalNetwork.IsLocalNetwork(context.remoteHost).ToPlainString()), new XElement("isLocalNetwork", LocalNetwork.IsLocalNetwork(context.remoteHost).ToPlainString()),
new XElement("ip", context.remoteHost.ToString()), new XElement("ip", context.remoteHost.ToString()),
new XElement("isMigrationEnabled", Config.instance.IsMigrationEnabled.ToPlainString()),
}; };
} }

@ -17,6 +17,7 @@ namespace FLocal.IISHandler.handlers.response {
} }
protected override IEnumerable<XElement> getSpecificData(WebContext context) { protected override IEnumerable<XElement> getSpecificData(WebContext context) {
if(!Config.instance.IsMigrationEnabled) throw new FLocalException("Migration is disabled");
string username; string username;
if(context.httprequest.Form["username"] != null && context.httprequest.Form["username"] != "") { if(context.httprequest.Form["username"] != null && context.httprequest.Form["username"] != "") {
username = context.httprequest.Form["username"]; username = context.httprequest.Form["username"];

@ -36,6 +36,7 @@
</tr> </tr>
</table> </table>
<br/> <br/>
<xsl:if test="isMigrationEnabled='true'">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround"> <table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr> <tr>
<td> <td>
@ -64,6 +65,7 @@
</tr> </tr>
</table> </table>
<br/> <br/>
</xsl:if>
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround"> <table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr> <tr>
<td> <td>

Loading…
Cancel
Save