public async Task <IActionResult> Login(string username, string password, string returnUrl) { var identity = authenticationService.Authenticate(username, password); if (identity == null) { return(RedirectToAction(nameof(Login))); } await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties()); return(string.IsNullOrWhiteSpace(returnUrl) ? RedirectToAction("Index", "Home") : (IActionResult)LocalRedirect(returnUrl)); }
public async Task <IActionResult> Login(string username, string password, string returnUrl) { var identity = authenticationService.Authenticate(username, password); if (identity == null) { return(RedirectToAction(nameof(Login), new { failed = true })); } await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { IsPersistent = true }); logger.LogInformation("User {username} signed in at {timestamp}", username, DateTime.Now); return(string.IsNullOrWhiteSpace(returnUrl) ? RedirectToAction("List", "Searches") : (IActionResult)LocalRedirect(returnUrl)); }