What is the exact part of the code you are having trouble with? The changing, the logging in?
If it is logging in, I'd prolly use something like this. I will not store passwords themselves, but I will store them encrypted.
alias newpass {
[color:green]; $md5 - I work with encrypted passwords only[/color]
[color:green]; $input - because it is more versatile than $?[/color]
if ($md5($input(Input password:,p,input request)) == %mypassword) {
[color:green]; user input his correct password[/color]
[color:green]; input the pass twice to prevent typos![/color]
var %pass1 = $md5($input(Enter new password:,p,input request))
var %pass2 = $md5($input(Confirm new password:,p,input request))
if (%pass1 == %pass2) {
[color:green]; two entered passes are the same[/color]
set %mypassword %pass1
echo -a Your password has been changed.
}
else {
[color:green]; two entered passes are different[/color]
echo -a You entered two different passwords. Your password has not been changed.
}
}
else {
[color:green]; user input a wrong password[/color]
echo -a You have entered the wrong password.
}
}
You could of course make this nicer by adding popups boxes for the messages instead of using echo...
Then for the authentication (assuming one gets 3 tries...)
[color:green]; a group to enable/disable the login code[/color]
#login on
alias login {
var %x = 1
[color:green]; allow for 3 attempts[/color]
while (%x <= 3) {
if ($md5($input(Input password:,p,input request)) == %mypassword) {
[color:green]; user has entered his password[/color]
echo -a Password accepted!
guser IDENTIFIED $nick 3
[color:green]; stop processing or he will be asked again![/color]
halt
}
else {
[color:green]; user provided a wrong password[/color]
echo -a You provided the wrong password. Please try again!
}
}
else {
[color:green]; Sorry, only 3 attempts allowed[/color]
echo -a You have tried to identify 3 times and failed. Goodbye.
}
}
#login end
And of course the necessary popups to turn the group on and off:
menu status,menubar {
$iif($group(#login) != on,Enable,Disable) Password System:$iif($group(#login) != on,.enable,.disable) #login
}
This is of course the very basics. I used the /guser to add the user to a userlist, then I would give access to people who have identified via the userlist (on LEVEL:EVENT.....)