I'm trying to implement the Reset Password functionality using UmbracoIdentity.
I got an error in:
I know that this is one of the Limitation of UmbracoIdentity, but I really need this function.
Here is my code:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ForgotPassword(ResetPasswordViewModel model)
{
//generate alpha-numeric string
var newPassword = MembershipHelpers.GetUniqueKey(10);
var resetmember = UserManager.FindByEmail(model.ResetEmail);
if (resetmember != null)
{
var userId = UserManager.FindByEmail(model.ResetEmail).Id;
UserManager.RemovePassword(userId);
UserManager.AddPassword(userId, newPassword);
//Send email to the user
var userEmail = new UserEmail()
{
EmailTo = resetmember.Email,
Message = $"You have requested a new password. Your new password is <b>{newPassword}</b>. You will be asked to change your password when you next log in.",
};
EmailHelpers.SendEmail(userEmail, "Reset", "Your new password");
return Json(new { status = "true", message = "Check your email..."});
}
else
{
return Json(new { status = "false");
}
}
If this is for frontend members, I use the MemberService to perform the actual change of the password.
var memberService = Services.MemberService;
var member = memberService.GetByEmail(form["email"]);
memberService.SavePassword(member, form["NewPassword"]);
member.LastPasswordChangeDate = DateTime.UtcNow;
Services.MemberService.Save(member);
Reset Password with UmbracoIdentity Package
Hi,
I'm trying to implement the
Reset Password
functionality using UmbracoIdentity.I got an error in:
I know that this is one of the Limitation of UmbracoIdentity, but I really need this function.
Here is my code:
Thanks,
Jin
Hi Jin, I'm facing the exact issue with my Umbraco 8 Solution. Did You manage to solve this - if so, would You care to share...?
Regards Robin :)
If this is for frontend members, I use the MemberService to perform the actual change of the password.
don't know if that is of any help.
is working on a reply...