Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | Email | NormalizedEmail | NormalizedUserName | UserName |
- +-----------------+--------------------+---------------------+-----------------+
- | test@here.com | TEST@HERE.COM | TEST@HERE.COM | test@here.com |
- public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
- {
- if (!ModelState.IsValid)
- {
- return View(model);
- }
- var user = await _userManager.FindByEmailAsync(model.Email);
- if (user == null)
- {
- // Don't reveal that the user does not exist
- return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
- }
- var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);
- if (result.Succeeded)
- {
- return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
- }
- AddErrors(result);
- return View();
- }
- | Email | NormalizedEmail | NormalizedUserName | UserName |
- +-----------------+--------------------+---------------------+-----------------+
- | test@here.com | TEST@HERE.COM | TEST | test@here.com |
- public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
- {
- ViewData["ReturnUrl"] = returnUrl;
- if (ModelState.IsValid)
- {
- // This doesn't count login failures towards account lockout
- // To enable password failures to trigger account lockout, set lockoutOnFailure: true
- var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
- if (result.Succeeded)
- {
- _logger.LogInformation(1, "User logged in.");
- return RedirectToLocal(returnUrl);
- }
- if (result.RequiresTwoFactor)
- {
- return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
- }
- if (result.IsLockedOut)
- {
- _logger.LogWarning(2, "User account locked out.");
- return View("Lockout");
- }
- else
- {
- ModelState.AddModelError(string.Empty, "Invalid login attempt.");
- return View(model);
- }
- }
- // If we got this far, something failed, redisplay form
- return View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement