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 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) {

@ -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"]);

@ -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"]));

@ -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");

@ -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,

@ -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()),
};
}

@ -17,6 +17,7 @@ namespace FLocal.IISHandler.handlers.response {
}
protected override IEnumerable<XElement> 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"];

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

Loading…
Cancel
Save