[Solved] Set Member Password programmatically
# help-with-umbraco
c
V13.5.3 Using the following but it doesn't set the password:
Copy code
var theMember = _memberService.GetByEmail(member.email);
theMember.RawPasswordValue = defaultPassword;
 _memberService.Save(theMember);
Have looked in the gitHub source but it doesn't tell me much. Any idea how we can pro grammatically set the password without knowing the random one assigned on member creation? Thanks
s
Hi, when creating a new user we use newMember.RawPasswordValue = _passwordHasher.HashPassword(model.Password); where passwordHasher is interface Umbraco.Cms.Core.Security.IPasswordHasher Other options which I saw when looking into the memberManager (IUmbracoUserManager interface). Dont know if this will work GeneratePasswordResetTokenAsync to generate a passwordtreset token and then Task ChangePasswordWithResetAsync(string userId, string token, string newPassword); Task GeneratePasswordResetTokenAsync(TUser user); I hope the first part will work as it is more straightfoward.
c
Fantastic, the easy one worked. That's very much!
13 Views