RegistrationEmail implemented

main
Inga 🏳‍🌈 15 years ago
parent 5d64016a2b
commit 04ab07ded1
  1. 2
      Builder/IISMainHandler/build.txt
  2. 25
      Common/dataobjects/Account.cs
  3. 4
      Common/dataobjects/Invite.cs
  4. 2
      IISMainHandler/handlers/request/MigrateAccountHandler.cs
  5. 2
      IISMainHandler/handlers/request/RegisterByInviteHandler.cs
  6. 5
      IISMainHandler/handlers/request/SettingsHandler.cs
  7. 2
      templates/Full/MigrateAccount.xslt
  8. 2
      templates/Full/RegisterByInvite.xslt
  9. 5
      templates/Full/Settings.xslt
  10. 2
      templates/Lite/MigrateAccount.xslt

@ -19,6 +19,7 @@ namespace FLocal.Common.dataobjects {
public const string FIELD_NEEDSMIGRATION = "NeedsMigration";
public const string FIELD_NAME = "Name";
public const string FIELD_IPADDRESS = "IpAddress";
public const string FIELD_REGISTRATIONEMAIL = "RegistrationEmail";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
@ -145,6 +146,21 @@ namespace FLocal.Common.dataobjects {
});
}
public void updateRegistrationEmail(string newEmail) {
ChangeSetUtil.ApplyChanges(new AbstractChange[] {
new UpdateChange(
TableSpec.instance,
new Dictionary<string, AbstractFieldValue>() {
{
TableSpec.FIELD_REGISTRATIONEMAIL,
new ScalarFieldValue(newEmail)
},
},
this.id
)
});
}
public static void checkNewPassword(string newPassword) {
if(newPassword.Length < 5) throw new FLocalException("Password is too short");
}
@ -159,7 +175,7 @@ namespace FLocal.Common.dataobjects {
}
}
public static KeyValuePair<AbstractChange, AbstractChange[]> getNewAccountChanges(string _name, string password, string ip) {
public static KeyValuePair<AbstractChange, AbstractChange[]> getNewAccountChanges(string _name, string password, string ip, string registrationEmail) {
string name = _name.Trim();
checkNewName(name);
checkNewPassword(password);
@ -186,6 +202,7 @@ namespace FLocal.Common.dataobjects {
{ Account.TableSpec.FIELD_PASSWORDHASH, new ScalarFieldValue(hashPassword(password, name.ToLower())) },
{ Account.TableSpec.FIELD_USERID, new ReferenceFieldValue(userInsert) },
{ Account.TableSpec.FIELD_IPADDRESS, new ScalarFieldValue(ip) },
{ Account.TableSpec.FIELD_REGISTRATIONEMAIL, new ScalarFieldValue(registrationEmail) },
}
);
var indicatorInsert = new InsertChange(
@ -206,7 +223,7 @@ namespace FLocal.Common.dataobjects {
);
}
public void migrate(string newPassword, string ip) {
public void migrate(string newPassword, string ip, string registrationEmail) {
checkNewPassword(newPassword);
if(!this.needsMigration) throw new FLocalException("Already migrated");
ChangeSetUtil.ApplyChanges(new AbstractChange[] {
@ -225,6 +242,10 @@ namespace FLocal.Common.dataobjects {
TableSpec.FIELD_IPADDRESS,
new ScalarFieldValue(ip)
},
{
TableSpec.FIELD_REGISTRATIONEMAIL,
new ScalarFieldValue(registrationEmail)
},
},
this.id
),

@ -84,11 +84,11 @@ namespace FLocal.Common.dataobjects {
}
private object createAccount_locker = new object();
public Account createAccount(string code, string name, string password, string ip) {
public Account createAccount(string code, string name, string password, string ip, string registrationEmail) {
lock(this.createAccount_locker) {
if(this.isUsed) throw new FLocalException("Invite is already used");
if(this.code != code) throw new FLocalException("Wrong code");
var rawChanges = Account.getNewAccountChanges(name, password, ip);
var rawChanges = Account.getNewAccountChanges(name, password, ip, registrationEmail);
var accountInsert = rawChanges.Key;
var changes = new List<AbstractChange>(rawChanges.Value);
changes.Add(

@ -23,7 +23,7 @@ namespace FLocal.IISHandler.handlers.request {
string check = Util.md5(match.Groups[1].Value + " " + Config.instance.SaltMigration + " " + account.id);
if(check != context.httprequest["check"]) throw new FLocalException("Wrong key (fhn:" + match.Groups[1].Value + ")");
if(context.httprequest.Form["password"] != context.httprequest.Form["password2"]) throw new FLocalException("Passwords mismatch");
account.migrate(context.httprequest.Form["password"], context.httprequest.UserHostAddress);
account.migrate(context.httprequest.Form["password"], context.httprequest.UserHostAddress, context.httprequest.Form["registrationEmail"]);
return account;
}

@ -17,7 +17,7 @@ namespace FLocal.IISHandler.handlers.request {
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");
return invite.createAccount(context.httprequest.Form["code"], context.httprequest.Form["login"], context.httprequest.Form["password"], context.httprequest.UserHostAddress);
return invite.createAccount(context.httprequest.Form["code"], context.httprequest.Form["login"], context.httprequest.Form["password"], context.httprequest.UserHostAddress, context.httprequest.Form["registrationEmail"]);
}
}

@ -19,6 +19,7 @@ namespace FLocal.IISHandler.handlers.request {
string currentPassword = context.httprequest.Form["currentPassword"];
string newPassword = context.httprequest.Form["newPassword"];
if(newPassword != context.httprequest.Form["newPassword2"]) throw new FLocalException("new passwords mismatch");
string registrationEmail = context.httprequest.Form["registrationEmail"];
int postsPerPage = int.Parse(context.httprequest.Form["postsPerPage"]);
int threadsPerPage = int.Parse(context.httprequest.Form["threadsPerPage"]);
int usersPerPage = int.Parse(context.httprequest.Form["usersPerPage"]);
@ -38,6 +39,10 @@ namespace FLocal.IISHandler.handlers.request {
context.account.updatePassword(newPassword);
}
if(registrationEmail != null && registrationEmail != "") {
context.account.updateRegistrationEmail(registrationEmail);
}
return new XElement[0];
}

@ -32,6 +32,8 @@
<input type="password" name="password" class="formboxes" /><br/>
<xsl:text>Ïîâòîðèòå ïàðîëü</xsl:text><br/>
<input type="password" name="password2" class="formboxes" /><br/>
<xsl:text>e-mail для восстановления пароля (необязательно)</xsl:text><br/>
<input type="text" name="registrationEmail" class="formboxes" />
<br/>
<input type="checkbox" name="constitution" value="constitution" id="constitution"/>
<label for="constitution"> Äà, ÿ ñîãëàñåí/ñîãëàñíà/ñîãëàñíî ñ òåì, ÷òî íà ýòîì ôîðóìå äåéñòâóåò </label>

@ -27,6 +27,8 @@
<input type="password" name="password" class="formboxes" /><br/>
<xsl:text>Ïîâòîðèòå ïàðîëü</xsl:text><br/>
<input type="password" name="password2" class="formboxes" /><br/>
<xsl:text>e-mail для восстановления пароля (необязательно)</xsl:text><br/>
<input type="text" name="registrationEmail" class="formboxes" />
<br/>
<input type="checkbox" name="constitution" value="constitution" id="constitution"/>
<label for="constitution"> Äà, ÿ ñîãëàñåí/ñîãëàñíà/ñîãëàñíî ñ òåì, ÷òî íà ýòîì ôîðóìå äåéñòâóåò </label>

@ -34,6 +34,11 @@
<br/>
<input type="password" name="newPassword2"/>
</p>
<p>
<xsl:text>e-mail для восстановления пароля (необязательно)</xsl:text>
<br/>
<input type="text" name="registrationEmail"/>
</p>
<p>
<xsl:text>Постов на страницу:</xsl:text>
<br/>

@ -32,6 +32,8 @@
<input type="password" name="password" class="formboxes" /><br/>
<xsl:text>Ïîâòîðèòå ïàðîëü</xsl:text><br/>
<input type="password" name="password2" class="formboxes" /><br/>
<xsl:text>e-mail для восстановления пароля (необязательно)</xsl:text><br/>
<input type="text" name="registrationEmail" class="formboxes" />
<br/>
<input type="checkbox" name="constitution" value="constitution" id="constitution"/>
<label for="constitution"> Äà, ÿ ñîãëàñåí/ñîãëàñíà/ñîãëàñíî ñ òåì, ÷òî íà ýòîì ôîðóìå äåéñòâóåò </label>

Loading…
Cancel
Save