public async Task <IActionResult> Login(LoginViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var user = _citizenRepository.Login(viewModel.Name, viewModel.Password); if (user == null) { ModelState.AddModelError(nameof(LoginViewModel.Name), "Не правильный логин или пароль"); return(View(viewModel)); } var claimsPrincipal = _citizenPresentation.GetClaimsPrincipal(user); await HttpContext.SignInAsync(claimsPrincipal); if (!string.IsNullOrEmpty(viewModel.ReturnUrl)) { return(Redirect(viewModel.ReturnUrl)); } return(RedirectToAction("Index", "Home")); }