From 04ab07ded13d824a97450fb8219ac50491a782ff Mon Sep 17 00:00:00 2001
From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Tue, 24 Aug 2010 17:04:07 +0000
Subject: [PATCH] RegistrationEmail implemented
---
Builder/IISMainHandler/build.txt | 2 +-
Common/dataobjects/Account.cs | 25 +++++++++++++++++--
Common/dataobjects/Invite.cs | 4 +--
.../handlers/request/MigrateAccountHandler.cs | 2 +-
.../request/RegisterByInviteHandler.cs | 2 +-
.../handlers/request/SettingsHandler.cs | 5 ++++
templates/Full/MigrateAccount.xslt | 2 ++
templates/Full/RegisterByInvite.xslt | 2 ++
templates/Full/Settings.xslt | 5 ++++
templates/Lite/MigrateAccount.xslt | 2 ++
10 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt
index 1b003ab..d17ea3a 100644
--- a/Builder/IISMainHandler/build.txt
+++ b/Builder/IISMainHandler/build.txt
@@ -1 +1 @@
-906
\ No newline at end of file
+908
\ No newline at end of file
diff --git a/Common/dataobjects/Account.cs b/Common/dataobjects/Account.cs
index 034b61a..fad9d29 100644
--- a/Common/dataobjects/Account.cs
+++ b/Common/dataobjects/Account.cs
@@ -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() {
+ {
+ 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 getNewAccountChanges(string _name, string password, string ip) {
+ public static KeyValuePair 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
),
diff --git a/Common/dataobjects/Invite.cs b/Common/dataobjects/Invite.cs
index 9f941c9..f6dd335 100644
--- a/Common/dataobjects/Invite.cs
+++ b/Common/dataobjects/Invite.cs
@@ -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(rawChanges.Value);
changes.Add(
diff --git a/IISMainHandler/handlers/request/MigrateAccountHandler.cs b/IISMainHandler/handlers/request/MigrateAccountHandler.cs
index 773c042..6d16fe9 100644
--- a/IISMainHandler/handlers/request/MigrateAccountHandler.cs
+++ b/IISMainHandler/handlers/request/MigrateAccountHandler.cs
@@ -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;
}
diff --git a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs b/IISMainHandler/handlers/request/RegisterByInviteHandler.cs
index 24b9b97..5ea8638 100644
--- a/IISMainHandler/handlers/request/RegisterByInviteHandler.cs
+++ b/IISMainHandler/handlers/request/RegisterByInviteHandler.cs
@@ -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"]);
}
}
diff --git a/IISMainHandler/handlers/request/SettingsHandler.cs b/IISMainHandler/handlers/request/SettingsHandler.cs
index d176af4..0f0b618 100644
--- a/IISMainHandler/handlers/request/SettingsHandler.cs
+++ b/IISMainHandler/handlers/request/SettingsHandler.cs
@@ -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];
}
diff --git a/templates/Full/MigrateAccount.xslt b/templates/Full/MigrateAccount.xslt
index f60453b..3a17ca2 100644
--- a/templates/Full/MigrateAccount.xslt
+++ b/templates/Full/MigrateAccount.xslt
@@ -32,6 +32,8 @@
Повторите пароль
+ e-mail для восстановления пароля (необязательно)
+
diff --git a/templates/Full/RegisterByInvite.xslt b/templates/Full/RegisterByInvite.xslt
index 1a8c75b..70db86b 100644
--- a/templates/Full/RegisterByInvite.xslt
+++ b/templates/Full/RegisterByInvite.xslt
@@ -27,6 +27,8 @@
Повторите пароль
+ e-mail для восстановления пароля (необязательно)
+
diff --git a/templates/Full/Settings.xslt b/templates/Full/Settings.xslt
index 91f17f1..71fdb85 100644
--- a/templates/Full/Settings.xslt
+++ b/templates/Full/Settings.xslt
@@ -34,6 +34,11 @@
+
+ e-mail для восстановления пароля (необязательно)
+
+
+
Постов на страницу:
diff --git a/templates/Lite/MigrateAccount.xslt b/templates/Lite/MigrateAccount.xslt
index f60453b..3a17ca2 100644
--- a/templates/Lite/MigrateAccount.xslt
+++ b/templates/Lite/MigrateAccount.xslt
@@ -32,6 +32,8 @@
Повторите пароль
+ e-mail для восстановления пароля (необязательно)
+