public async Task <IActionResult> Register(RegisterModel model) { if (ModelState.IsValid) { UserDTO user = _authorizationService.FindUserByEmail(new UserDTO { Email = model.Email, Password = model.Password }); if (user == null) { _authorizationService.AddUser(new UserDTO { Email = model.Email, Password = model.Password }); await Authenticate(model.Email); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Некорректные логин и(или) пароль"); } } return(View(model)); }