Umbraco 8 - Generate Password Reset Token (a .NET feature)
Dear Community,
I am working on a feature where if registered member forgets the password. he should be able to get a password reset link via email where the password can be changed.
I have seen ASP.NET features where this can be easily done as below:
I was trying to search for such feature in our api be unable to located any.
If I could get some help or guidance or any alternative to this feature provided would be great.
I added a couple of properties to the member and use those to store a token
for the token I just generate a guid and strip the '-' I then store it against the members profile and send them an email, when they click the confirmation link, I check the created token and give them a form where they can set a new password.
var token = GenerateUniqueCode();
user.SetValue("confirmationToken", token);
user.SetValue("tokenExpires", DateTime.UtcNow.AddHours(48));
memberService.Save(user);
In the handler for the reset form, I do the following
#region reset the Umbraco password
//there was a password, so lets do the reset
memberService.SavePassword(member, form["NewPassword"]);
member.LastPasswordChangeDate = DateTime.UtcNow;
//remove the token and expiry
member.SetValue("confirmationToken", "");
member.SetValue("tokenExpires", DateTime.UtcNow.AddDays(-30));
Services.MemberService.Save(member);
#endregion
Umbraco 8 - Generate Password Reset Token (a .NET feature)
Dear Community,
I am working on a feature where if registered member forgets the password. he should be able to get a password reset link via email where the password can be changed.
I have seen ASP.NET features where this can be easily done as below:
Where this code/token can be send in the link as qs parameter and when member clicks the link, options for setting new password can be provided.
Finally with this code/token to reset a new password for that member/user as below:
I was trying to search for such feature in our api be unable to located any. If I could get some help or guidance or any alternative to this feature provided would be great.
Thank you in advance!
Best Regards,
Ranjit
I added a couple of properties to the member and use those to store a token
for the token I just generate a guid and strip the '-' I then store it against the members profile and send them an email, when they click the confirmation link, I check the created token and give them a form where they can set a new password.
In the handler for the reset form, I do the following
Hi Huw,
Sounds good!
I tried this and works like charm... :)
Thank you very much!
Regards,
Ranjit
Glad to be of help.
is working on a reply...