Esempio n. 1
0
 public ActionResult RegisterNewUser(RegisterUserViewModel user)
 {
     if (!ModelState.IsValid)
     {
         return(View("Register", user));
     }
     if (!string.Equals(user.Password, user.RepeatPassword))
     {
         ModelState.AddModelError(string.Empty, "passwords don't match");
         return(View("Register", user));
     }
     if (_chatRepository.IsUserRegistered(user.Email))
     {
         ModelState.AddModelError("Email", "the email is not available");
         return(View("Register", user));
     }
     _chatRepository.AddNewUser(user);
     AuthorizeUser(user.Email, user.RememberMe);
     return(RedirectToAction("Index", "Chat"));
 }