From 6cd2b3e5e02d3144cefe99cd70ebf72301b81c97 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Fri, 2 Jul 2010 11:44:21 +0000 Subject: [PATCH] 'Change password' feature implemented --- Builder/IISMainHandler/build.txt | 2 +- Builder/IISUploadHandler/build.txt | 2 +- Common/dataobjects/Account.cs | 4 ++++ IISMainHandler/handlers/request/SettingsHandler.cs | 9 +++++++++ templates/Full/Settings.xslt | 14 ++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 4c9bbbf..281cd66 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -468 \ No newline at end of file +469 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index cbd6012..e0d1ea1 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -204 \ No newline at end of file +205 \ No newline at end of file diff --git a/Common/dataobjects/Account.cs b/Common/dataobjects/Account.cs index 5eb46da..4946e31 100644 --- a/Common/dataobjects/Account.cs +++ b/Common/dataobjects/Account.cs @@ -128,6 +128,10 @@ namespace FLocal.Common.dataobjects { return Util.md5(password + " " + Config.instance.SaltMigration + " " + this.id); } + public bool checkPassword(string password) { + return this.hashPassword(password) == this.passwordHash; + } + public void updatePassword(string newPassword) { ChangeSetUtil.ApplyChanges(new AbstractChange[] { new UpdateChange( diff --git a/IISMainHandler/handlers/request/SettingsHandler.cs b/IISMainHandler/handlers/request/SettingsHandler.cs index 1f3aaa8..6675df6 100644 --- a/IISMainHandler/handlers/request/SettingsHandler.cs +++ b/IISMainHandler/handlers/request/SettingsHandler.cs @@ -16,6 +16,9 @@ namespace FLocal.IISHandler.handlers.request { } protected override XElement[] Do(WebContext context) { + string currentPassword = context.httprequest.Form["currentPassword"]; + string newPassword = context.httprequest.Form["newPassword"]; + if(newPassword != context.httprequest.Form["newPassword2"]) throw new FLocalException("new passwords mismatch"); int postsPerPage = int.Parse(context.httprequest.Form["postsPerPage"]); int threadsPerPage = int.Parse(context.httprequest.Form["threadsPerPage"]); int usersPerPage = int.Parse(context.httprequest.Form["usersPerPage"]); @@ -27,8 +30,14 @@ namespace FLocal.IISHandler.handlers.request { if((usersPerPage < 1) || (usersPerPage > 200)) throw new FLocalException("wrong number for usersPerPage"); if((uploadsPerPage < 1) || (uploadsPerPage > 200)) throw new FLocalException("wrong number for uploadsPerPage"); + if(!context.account.checkPassword(currentPassword)) throw new FLocalException("wrong password"); + AccountSettings.Save(context.session.account, postsPerPage, threadsPerPage, usersPerPage, uploadsPerPage, skin); + if(newPassword != null && newPassword != "") { + context.account.updatePassword(newPassword); + } + return new XElement[0]; } diff --git a/templates/Full/Settings.xslt b/templates/Full/Settings.xslt index 8a86d70..a28d91c 100644 --- a/templates/Full/Settings.xslt +++ b/templates/Full/Settings.xslt @@ -19,6 +19,20 @@
+

+ Ваш текущий пароль +
+ +

+

+ Если вы хотите изменить пароль, введите сюда новый пароль +
+ +
+ и повторите его +
+ +

Постов на страницу: