ASP.NET Identity reset password

前端 未结 10 1111
无人及你
无人及你 2020-12-02 05:09

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

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 05:39

    string message = null;
    //reset the password
    var result = await IdentityManager.Passwords.ResetPasswordAsync(model.Token, model.Password);
    if (result.Success)
    {
        message = "The password has been reset.";
        return RedirectToAction("PasswordResetCompleted", new { message = message });
    }
    else
    {
        AddErrors(result);
    }
    

    This snippet of code is taken out of the AspNetIdentitySample project available on github

提交回复
热议问题