public void AddUser(User user) { // Validate foreach (var u in data.Users) { if (u.Email == user.Email) { throw new Exception("User already exist"); } } // hash password user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password,9); data.Users.Add(user); Save(); }
public ActionResult Index(User user) { var auth = new Authorization(); auth.AddUser(user); // Create session FormsAuthentication.SetAuthCookie(user.Email, true); return RedirectToAction("Login", "Account"); }