public async Task <ActionResult> Login(LoginViewModel model) { await SetInitialDataAsync(); if (ModelState.IsValid) { ApplicationUserDTO applicationUserDTO = new ApplicationUserDTO { Email = model.Email, Password = model.Password }; ClaimsIdentity claim = await ApplicationUserService.Authenticate(applicationUserDTO); if (claim == null) { ModelState.AddModelError("", "Неверный логин или пароль."); } else { AuthenticationManager.SignOut(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claim); return(RedirectToAction("Index", "Home")); } } return(View(model)); }