Problem updating members password using umbraco version 7.6.1
Just wonder if anyone can help.
I'm trying to update the members password with the following code:
var memberService = Services.MemberService;
var member = memberService.GetById(model.Id);
memberService.SavePassword(member, model.Password);
However, when I run the code I get the following error:
System.NotSupportedException: This provider does not support manually changing the password at Umbraco.Core.Security.MembershipProviderBase.ChangePassword(String username, String oldPassword, String newPassword) at Umbraco.Core.Services.MemberService.SavePassword(IMember member, String password)
I have the same code on other sites and it works, what am I doing wrong?
You have set allowManuallyChangingPassword="false" in your web.config file on the UmbracoMembershipProvider, which is best practice. This ensures that you provide the old password AND the changed password so people can not randomly change your password if you step away from your computer for a second and forget to lock it.
If you are not currently asking for the old password or can't/don't want to then set allowManuallyChangingPassword="true" on the UmbracoMembershipProvider.
Ah, this is a very good point! We should have an additional method that supports passing in the old password. Could you create an issue for that on http://issues.umbraco.org please?
How does Umbraco change a member/user password? There is an option to reset a member's/user's password in the backoffice without knowing the old password.
In my code, I may need to use different methods depending on the scenarios:
a method for when I need to reset a password without knowing their password (as in they forgot it, and I have gone through the steps to authenticate them)
I'm having a similar issue, but with newly created accounts (as in through a register controller), How do you create a new user and set a password that the user enters though a registration form?
I've currently got:
//convert model to Register
var newUser = Services.MemberService.CreateMember(model.Email, model.Email, model.Email, "user");
memberService.SavePassword(newUser, model.Password);
memberService.Save(newUser);
But i'm getting the same error above:
System.NotSupportedException: This provider does not support manually changing the password
How do you set a newly created members password when your creating them in Umbraco?
Hi there, not sure if you ever resolved this, but after days (literally) I came up with the following using exclusively the member service. Note the order of saving the member is very important here as you are likely saving a password into a member that does not exist yet...
Here is the controller -hope this helps...
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Register(AccountModels.RegistrationModel model)
{
if (ModelState.IsValid)
{
try
{
var memberService = Services.MemberService;
if (memberService.Exists(model.Email))
{
ModelState.AddModelError(String.Empty, "Member already exists with this email address");
return CurrentUmbracoPage();
}
var member = memberService.CreateMember(model.Email, model.Email, model.FirstName + " " + model.LastName, "Client");
//Now add custom attributes to the user type
member.SetValue("firstName", model.FirstName);
member.SetValue("lastName", model.LastName);
member.IsApproved = true;
//Save the member!!
memberService.Save(member);
//Assign role
memberService.AssignRole(member.Id, "Client");
// save member first, then save their password as there would be no member to save into otherwise
memberService.SavePassword(member, model.Password);
//Check to see now if the member really exists. If so, login and redirect...
if (memberService.Exists(member.Id))
{
FormsAuthentication.SetAuthCookie(model.Email, false);
return Redirect("/account/");
}
}
catch (Exception e)
{
ModelState.AddModelError("", "Could not create new user. Exception details: " + e);
}
}
return CurrentUmbracoPage();
}
Problem updating members password using umbraco version 7.6.1
Just wonder if anyone can help.
I'm trying to update the members password with the following code:
However, when I run the code I get the following error:
I have the same code on other sites and it works, what am I doing wrong?
Thanks
Darren
You have set
allowManuallyChangingPassword="false"
in your web.config file on theUmbracoMembershipProvider
, which is best practice. This ensures that you provide the old password AND the changed password so people can not randomly change your password if you step away from your computer for a second and forget to lock it.If you are not currently asking for the old password or can't/don't want to then set
allowManuallyChangingPassword="true"
on theUmbracoMembershipProvider
.Is there any way of doing this programmatically?
Hi Sebastiaan,
Thank you very much, that works :)
How would I go about passing the old password in?
The 'Services.MemberService.SavePassword()' only takes two parameters:
Thanks again
Darren
Ah, this is a very good point! We should have an additional method that supports passing in the old password. Could you create an issue for that on http://issues.umbraco.org please?
Hi Sebastiaan,
I've created an issue report on http://issues.umbraco.org
Thanks again for your help
Darren
Just came across this issue!
How does Umbraco change a member/user password? There is an option to reset a member's/user's password in the backoffice without knowing the old password.
In my code, I may need to use different methods depending on the scenarios:
In order to address the first scenario above, do I have to set
allowManuallyChangingPassword="true"
?Hi Sebastiaan
I'm having a similar issue, but with newly created accounts (as in through a register controller), How do you create a new user and set a password that the user enters though a registration form?
I've currently got:
But i'm getting the same error above: System.NotSupportedException: This provider does not support manually changing the password
How do you set a newly created members password when your creating them in Umbraco?
Many thanks Chris
Currently the only workaround is to set
allowManuallyChangingPassword="true"
on theUmbracoMembershipProvider
.This will be fixed soon (hopefully for the next release), follow this issue: http://issues.umbraco.org/issue/U4-9917
I have a similar issue as Chris for a registration form, which has password and password confirm fields.
Changing
allowManuallyChangingPassword
to true fixed it for now.I am running on Umbraco v. 7.6.3
/Bjarne
Hi there, not sure if you ever resolved this, but after days (literally) I came up with the following using exclusively the member service. Note the order of saving the member is very important here as you are likely saving a password into a member that does not exist yet...
Here is the controller -hope this helps...
Cheers,
Jamie
is working on a reply...