rejetto forum
Software => HFS ~ HTTP File Server => Topic started by: luca69 on January 27, 2009, 05:15:06 PM
-
I played a little bit with the admin panel and I found useful for the users to have the possibility to change the password by themselves.
This is my code:
[changepass]
{.if | %user% |
<html>
<head>
<title>Pass Changer</title>
</head>
<body>
<b><font size="4"> Welcome %user% ! </b>
<p>
<br><font size="4"> Then type the new password and click on Change. Leave it blanck to remove the password.
<p>
<form method=post action="/~userpasschange">
<table>
<tr><td align=left><b><font size="4"><font size="4">New Password</font></b></font></b><td><b><font size="4">: </font></b><span style="background-color: #000000"><input name=pass type=password style="font-size:10pt; font-weight:bold; border:1px solid #88f" size="20" ></span>
<tr><td align=left><font size="4">Click <a href="/">here</a> to return to HOME.</font><td align=center><input type=submit value="Change">
</tr></table>
</form>
</body>
</html>
|{.section|usererror.}.}
[userpasschange]
{.if | %user% |
<html>
<head>
<title>Pass Changer</title>
</head>
<body>
{.set account|%user%|password={.postvar|pass.}.}
<p><font size="4">Password changed!</font></p>
<p>Click <a href="/">here</a> to return to HOME.</p>
</body>
</html>
|{.section|usererror.}.}
[usererror]
<html>
<head>
<title>Error</title>
</head>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6"><b>You must login before chaning the password.</b></font></p>
<p align="center"> </p>
<p align="center"> </p>
<p>Click <a href="/">here</a> to return to HOME.</p>
</body>
</html>
To have the menu entry, you have to modify the current template and add the second line in the following peace of code:
{.if not| %user% | <li><a href="~login"><img src="/~img27"> Login</a></li> .}
{.if | %user% | <li><a href="/~changepass"> Change password</a></li> .}
{.if| {.get|can upload.} | <li><a href="~upload"><img src="/~img32"> Upload</a></li> .}
{.if| {.and | {.get|can archive.} | {.not|{.?search.}.} .}
Open: I think it is a good idea to ask the user twice for the new password and check if the two entry match; if not the user shall be prompt for the new password again.
-
Ooo this is a very nice idea and I think I'll give it a test run when I get home. Thanks for sharing.
-
Ooo this is a very nice idea and I think I'll give it a test run when I get home. Thanks for sharing.
Let me know what you think about it. Hints are welcome ;)
-
have a look at
http://www.rejetto.com/forum/index.php?topic=6590
uhm I checked the latest version and I found:
{.if|{.^allow password.} | <li><a href="/~error">Change Password</a></li> .}
This means that every time a user tries to change the password he/she gets an error!
I'll change the code and I'll make it compatible with 211 (new macro names!)
-
luca69
Let me know what you think about it. Hints are welcome
Thanks for sharing, works fine in default tpl, here. Very useful :)
-
Update: now the code ask for password twice and if there is a mismatch the user is prompt to enter the new password again.
[changepass]
{.if | %user% |
<html>
<head>
<title>Pass Changer</title>
<script type="text/javascript">
function validatePassword(form){
if (form.pass1.value != form.pass2.value){
alert("Password do not match: please enter again.");
return false;
}
return true;
}
</script>
</head>
<body>
<b><font size="4"> Welcome %user% ! </b>
<p>
<br><font size="4"> Then type the new password and click on Change. Leave it empty to remove the password.
<p>
<form method=post action="/~userpasschange" onsubmit="return validatePassword(this);">
<table>
<tr><td align=left><b><font size="4"><font size="4">New Password</font></b></font></b><td><b><font size="4">: </font></b><span style="background-color: #000000"><input name=pass1 type=password style="font-size:10pt; font-weight:bold; border:1px solid #88f" size="20" ></span>
<tr><td align=left><b><font size="4"><font size="4">Type Password again</font></b></font></b><td><b><font size="4">: </font></b><span style="background-color: #000000"><input name=pass2 type=password style="font-size:10pt; font-weight:bold; border:1px solid #88f" size="20" ></span>
<tr><td align=left><font size="4">Click <a href="/">here</a> to return to HOME.</font><td align=center><input type=submit value="Change" >
</tr></table>
</form>
</body>
</html>
|{.section|usererror.}.}
[userpasschange]
{.if |%user%|
<html>
<head>
<title>Pass Changer</title>
</head>
<body>
{.set account|%user%|password={.postvar|pass1.}.}
<p><font size="4">Password changed!</font></p>
<p>Click <a href="/">here</a> to return to HOME.</p>
</body>
</html>
|{.section|usererror.}.}
[usererror]
<html>
<head>
<title>Error</title>
</head>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6"><b>You must login before chaning the password.</b></font></p>
<p align="center"> </p>
<p align="center"> </p>
<p>Click <a href="/">here</a> to return to HOME.</p>
</body>
</html>