Pergunta

How can I get the password of a user in the new ASP.NET Identity system using webforms? Or how can I reset without knowing the current one (user forgot password)?

Foi útil?

Solução

I tied this way to reset password and send it to the user

if (userId != string.Empty)
        {
            string _newPass = RandomPass();

            if (manager.HasPassword(userId))
            {
                IdentityResult ir1 = manager.RemovePassword(userId);
                if (ir1.Succeeded)
                {
                    IdentityResult ir2 = manager.AddPassword(userId, _newPass);

                    if (ir1.Succeeded && ir2.Succeeded)
                    {
                        //Send password to user via sms or email
                        Response.Redirect("~/RecoverPassword?m=ChangePwdSuccess");
                    }
                    else
                    {
                        AddErrors(ir1);
                        AddErrors(ir2);
                    }
                }
            }
        }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top