Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Josip 169 posts 612 karma points c-trib
    1 week ago
    Josip
    0

    Programaticaly change password

    How can i change members password?

    When I try this:

    if (System.Web.Security.Membership.ValidateUser(username, model.OldPassword))
            {
                var memberService = Services.MemberService;
                var member = memberService.GetByUsername(username);
    
                memberService.SavePassword(member, model.NewPassword);
                memberService.Save(member);
    
                return Redirect("/");
            }
    

    I get this error: This provider does not support manually changing the password

    I know that i can set allowManuallyChangingPassword="true" on the UmbracoMembershipProvider, but is there any other way ?

    BR

  • Harikrishna Parmar 20 posts 173 karma points
    1 week ago
    Harikrishna Parmar
    0

    Please try this code block :

         var user = Members.CurrentUserName;
         if (Members.GetByUsername(user) != null)
         {
             var services = Current.Services.MemberService;
             var servicesResult = services.GetByUsername(user);
             services.SavePassword(servicesResult, model.Password);
         }
    

    or you can also try :

        if (Members.GetByEmail(model.Email) != null)
        {
               var services = Current.Services.MemberService;
               var servicesResult = services.GetByEmail(model.Email);
               services.SavePassword(servicesResult, model.Password);            
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft