public async Task <IActionResult> SignIn(SignInModel model) { if (ModelState.IsValid) { // Validate the credentislas bool validCredentials = await _accountRepository.ValidateCredentials(model.Username, model.Password); if (validCredentials) { // Sign-in the user account await HttpContext.SignInAsync(_accountRepository.CreateClaimPrincipal(model.Username)); // Redirect to the default page or redirect URL if (string.IsNullOrWhiteSpace(model.Redirect)) { return(RedirectToAction("Index", "Admin")); } else { return(LocalRedirect(model.Redirect)); } } else { // Invalid credentials, set model error ModelState.AddModelError(nameof(SignInModel.Password), "Invalid credentials"); return(View(model)); } } else { // Invalid model state return(View(model)); } }