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. 2
      IISMainHandler/handlers/request/LoginHandler.cs
  4. 3
      IISMainHandler/handlers/request/RegisterByInviteHandler.cs
  5. 2
      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,6 +30,7 @@ namespace FLocal.IISHandler.handlers.request {
protected override XElement[] Do(WebContext context) {
if(Config.instance.IsMigrationEnabled) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["name"]);
if(tmpAccount.needsMigration) {
@ -37,6 +38,7 @@ namespace FLocal.IISHandler.handlers.request {
}
} catch(NotFoundInDBException) {
}
}
Account account = Account.tryAuthorize(context.httprequest.Form["name"], context.httprequest.Form["password"]);
Session session = Session.create(account);

@ -14,6 +14,8 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterByInviteHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) {
if(Config.instance.IsMigrationEnabled) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
if(tmpAccount.needsMigration) {
@ -21,6 +23,7 @@ namespace FLocal.IISHandler.handlers.request {
}
} catch(NotFoundInDBException) {
}
}
Invite invite = Invite.LoadById(int.Parse(context.httprequest.Form["inviteId"]));
if(invite.isUsed) throw new FLocalException("Invite is already used");

@ -14,6 +14,7 @@ namespace FLocal.IISHandler.handlers.request {
class RegisterHandler : AbstractNewAccountHandler {
protected override Account DoCreateAccount(WebContext context) {
if(Config.instance.IsMigrationEnabled) {
try {
Account tmpAccount = Account.LoadByName(context.httprequest.Form["login"]);
if(tmpAccount.needsMigration) {
@ -21,6 +22,7 @@ namespace FLocal.IISHandler.handlers.request {
}
} 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");

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