【发布时间】:2019-05-09 21:34:51
【问题描述】:
我想在我的应用程序中更新密码。 这是我的登录 IAction
控制器
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> Login(string returnUrl = null)
{
// Clear the existing external cookie to ensure a clean login process
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
ViewData["ReturnUrl"] = returnUrl;
return View();
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
{
if (ModelState.IsValid)
{
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return RedirectToLocal(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToAction(nameof(LoginWith2fa), new { returnUrl, model.RememberMe });
}
if (result.IsLockedOut)
{
_logger.LogWarning("User account locked out.");
return RedirectToAction(nameof(Lockout));
}
else
{
ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return View(model);
}
}
return View(model);
}
现在我当前的电子邮件和密码是
电子邮件:john@gmail.com
密码:john@gmail.com123
我想将密码 john@gmail.com123 更新为 john@gmail.com677
【问题讨论】:
-
ASP.Net Identity 有一个 UserManager。
-
你能告诉我如何更新当前密码吗?
标签: asp.net asp.net-core asp.net-identity entity-framework-core asp.net-core-2.0