So the main problem was that the ChangePassword method did not validate the old password.
We decided to use the next approach:
var attempt = new Attempt<PasswordChangedModel>();
if (Membership.ValidateUser(model.UserName, model.PasswordOld))
{
attempt = membershipHelper.ChangePassword(model.UserName, passwordModel, membershipProviderName);
}
if (!attempt.Success)
{
throw new ChangeMembersPasswordException("Failed to change password!!");
}
Change members password programmatically
I'm new in Umbraco. I need to implement changing members password.
I have the endpoint:
UpdatePasswordModel contains UserName, OldPassword, NewPassword.
Has ChangePassword metdod some validation for old and new passwords? What is the best way to change members password?
Hi Mikhail
There is a param in Umbraco Security Settings that can specify a regular expression for a password - "passwordStrengthRegularExpression"
https://our.umbraco.com/Documentation/Reference/Security/Security-settings/
But I'm not sure that it will work if you change a password through the code.
Thanks,
Alex
Hi Mikhail
Let us know if you found a solution.
Thanks, Alex
You can checking correct username and password:
if (System.Web.Security.Membership.ValidateUser(model.UserName, model.PasswordOld)) {
_membershipHelper.ChangePassword(model.UserName, passwordModel, "UmbracoMembershipProvider");
}
So the main problem was that the
ChangePassword
method did not validate the old password. We decided to use the next approach:is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.