public ActionResult RegisterForm(RegisterControllerRegisterVM model) { TryUpdateModel(model); if (ModelState.IsValid) { User user = new User(); user.FirstName = model.FirstName; user.LastName = model.LastName; user.UserName = model.UserName; user.Password = model.Password; userRepository.Save(user); Session["User"] = user; AuthenticationService.AuthenticateUser(user.UserName,user.Password); return RedirectToAction("ListContact","Contact"); } return View(model); }
public static bool AuthenticateUser(string username, string password) { UserRepository userRepository = new UserRepository(); LoggedUser = userRepository.GetAll(filter: u => u.UserName == username && u.Password == password).FirstOrDefault(); return LoggedUser != null; }