public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { if (!UsersManager.CanSignIn(context, Input.Email)) { ModelState.AddModelError(string.Empty, "User either not exists or application has not been approved yet"); return(Page()); } var result = await signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure : true); if (result.Succeeded) { logger.LogInformation("User logged in."); return(LocalRedirect(returnUrl)); } if (result.IsLockedOut) { logger.LogWarning("User account locked out."); return(RedirectToPage("./Lockout")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(Page()); } } return(Page()); }