var memberService = ApplicationContext.Current.Services.MemberService;
var member = memberService.GetById(AppHelper.GetCurrentUserId());
memberService.SavePassword(member, model.Password);
I'm working with member. I'm trying the following code, member come back null.
private int GetCurrentUserId()
{
var userService = ApplicationContext.Current.Services.UserService;
return userService.GetByUsername(HttpContext.Current.User.Identity.Name).Id;
}
public void EditYourLoginDetails(ApplicationViewModel model)
{
//var m = Membership.GetUser();
var password = "password123";
var memberService = ApplicationContext.Current.Services.MemberService;
var member = memberService.GetById(GetCurrentUserId());
ApplicationContext.Current.Services.MemberService.SavePassword(member, password);
}
var password = "password123";
var memberService = ApplicationContext.Current.Services.MemberService;
var membersipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
var member = memberService.GetByUsername(membersipHelper.CurrentUserName);
ApplicationContext.Current.Services.MemberService.SavePassword(member, password);
Alex, I have a textbox that users can type in their new passwords.
How do you apply the password validation rules to the textbox i.e. password must be minimum of 10 charters etc.
Identity - Password reset for Umbraco members
Hi folks, I'm trying to allow users to reset their passwords, does anyone have code snippet I could look at?
I have been trying to reset the password with the following code;
Hi Tom
You can use MemberService SavePassword(IMember member, "newSecretPass1234") method as well:
https://our.umbraco.org/documentation/reference/management/services/memberservice#savepassword-imember-member-newsecretpass1234
Thanks,
Alex
Hi Alex, is this for the Identity framework?
It's general for Umbraco members.
Hi Alex, Umbraco 7 is now is the Identity framework for members, I think..
How would you implement
.SavePassword(IMember member, "newSecretPass1234");
can you provide example...
I'm trying the following snippet
Receiving error;
AppHelper does not exist in current context???
Tom, what is "AppHelper.GetCurrentUserId()"?
Are you working with users or members?
I'm working with member. I'm trying the following code, member come back null.
Tom, in first method you work woth Users in second with members :)
Member is an authenticated customer for front end site.
User is an authenticated user for Umbraco backend.
Thanks,
Alex
Thanks Alex, how do I reset a member password?
Tom, try this code:
Hi Alex, I tried your code, error at the last line.....
This provider does not support manually changing the password
Tom, please, check this flag "allowManuallyChangingPassword"="false" in your web.config file, read more about it here -
https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/85722-problem-updating-members-password-using-umbraco-version-761#comment-271567
"allowManuallyChangingPassword" should be true
Thanks,
Alex
Thanks Alex, much appreciated.
Alex, I have a textbox that users can type in their new passwords. How do you apply the password validation rules to the textbox i.e. password must be minimum of 10 charters etc.
Tom, are you using mvc razor coding?
Maybe some js validation?
Thanks,
Alex
is working on a reply...