R2D2 Posted March 27, 2015 Posted March 27, 2015 Hi! I'm trying to create a script which in case of user has forgotten his/hers password resets the account with a new random password and e-mails it to recipient. Here it goes (Don't mind the dialogues, if you don't speak Finnish : Show Custom Dialog [ Title: "Resetoi salasana?"; Message: "Tämä nollaa käyttäjän unohtuneen salasanan.¶¶Oletko varma, että haluat jatkaa?"; Default Button: “Peruuta”, Commit: “Yes”; Button 2: “Resetoi!”, Commit: “Yes” ] If [ Get ( LastMessageChoice ) = 1 ] Exit Script [ ] End If Set Variable [ $$pswd; Value:Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round (Random * 61; 0)+1; 1) & Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round(Random * 61; 0)+1; 1) & Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round(Random * 61; 0)+1; 1) & Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round(Random * 61; 0)+1; 1) & Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round(Random * 61; 0)+1; 1) & Middle("123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ!?"; Round(Random * 61; 0)+1; 1) ] Reset Account Password [ Account Name: STAFF::tUserName; New Password: $$pswd ] [ Expire password ] Send Mail [ Send via SMTP Server; To: STAFF::teMail; Subject: "Salasana resetoitu"; Message: "Salasanasi on nyt resetoitu" & ¶ & ¶& "Uusi salasanasi on: " & $$pswd & ¶ & ¶& "Huomioi, että järjestelmä erottelee pienet ja isot kirjaimet" & ¶ & "Salasana tulee muuttaa ensimmäisellä sisäänkirjautumisella järjestelmään"; Name: "Administrator"; Email Address: "[email protected]"; Reply-To Address: "[email protected]"; SMTP Server: CAL:: tgMailServer; Port: CAL::tgMailAccountPortNmbr; Use SSL; Authentication Type: Plain Password; User Name: CAL:: tgMailAccountName; Password: CAL::tgMailAccountPswd ] [ No dialog ] Show Custom Dialog [ Title: "Resetoitu"; Message: "Käyttäjän " & STAFF::cLastFirstName & " salasana on nyt resetoitu.¶ Uusi salasana on: " & $$pswd & ¶ & "Käyttäjän tulee vaihtaa salasana, kun kirjautuu seuraavan kerran järjestelmään."; Default Button: “OK”, Commit: “Yes” ] Commit Records/Requests [ Skip data entry validation; No dialog ] But I keep getting error code 5 (Command is invalid (for example, a Set Field script step does not have a calculation specified)) every time in step "Reset Account" and the account fails to be resetted to new password. I also tried to create a text field where new random password is temporarily stored and then used is Reset accoount step but without success. If I use a "static" new password in that step (for example: "New Password" every time), it works. What is wrong in that script or can I get around this some how? Thanks again in advance!
comment Posted March 27, 2015 Posted March 27, 2015 What is the exact error message you get (a screenshot would be most helpful, unless your application is giving them in Finnish)?
R2D2 Posted March 27, 2015 Author Posted March 27, 2015 The exact error message (in Debugger window) is that "Last error: 5". During the script (when not debugging) there is no error signals. E-mailing works, but the account does not reset (i.e. new password does not work, only the old).
Wim Decorte Posted March 27, 2015 Posted March 27, 2015 When you debug the script, at what step exactly does error 5 show up?
R2D2 Posted March 27, 2015 Author Posted March 27, 2015 Right after I commit line: Reset Account Password [ Account Name: STAFF::tUserName; New Password: $pswd ] [ Expire password ]
comment Posted March 27, 2015 Posted March 27, 2015 I cannot reproduce your problem. Does the attached file work for you? ResetPassword.fp7.zip Unrelated to your problem, but important: The variable holding the temporary password should be local ($pswd), not global ($$pswd). Global variables persist until the end of the session - and that poses a security risk in this case. The variable should expire when the script exits. BTW, the Commit Records step is redundant, since you're not modifying any records. 1
R2D2 Posted March 27, 2015 Author Posted March 27, 2015 Ok... Actually it seems that problem was in STAFF::tUserName field because for some reason it was left empty in my data. Comment's test file worked perfectly. And now this resetting works also in my file. I used $$pswd only to test if that was the reason. Now it is changed back to $pswd. Thank you so much for your help!
Recommended Posts
This topic is 3528 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now