'Change password' feature implemented

main
Inga 🏳‍🌈 14 years ago
parent 71fd56fa95
commit 6cd2b3e5e0
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 4
      Common/dataobjects/Account.cs
  4. 9
      IISMainHandler/handlers/request/SettingsHandler.cs
  5. 14
      templates/Full/Settings.xslt

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

@ -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];
}

@ -19,6 +19,20 @@
<tr>
<td class="lighttable">
<form method="post" action="/do/Settings/">
<p>
<xsl:text>Ваш текущий пароль</xsl:text>
<br/>
<input type="password" name="currentPassword"/>
</p>
<p>
<xsl:text>Если вы хотите изменить пароль, введите сюда новый пароль</xsl:text>
<br/>
<input type="password" name="newPassword"/>
<br/>
<xsl:text>и повторите его</xsl:text>
<br/>
<input type="password" name="newPassword2"/>
</p>
<p>
<xsl:text>Ïîñòîâ íà ñòðàíèöó:</xsl:text>
<br/>

Loading…
Cancel
Save