public ActionResult Login(UserAccount userAccount) { //Get the login information and make sure it matches Boolean userLoggedIn = _userManager.LogInUser(userAccount); if (userLoggedIn) { UserAccount userLogin = _userManager.GetOneByEmail(userAccount.Email); Session["UserID"] = userLogin.Id; FormsAuthentication.SetAuthCookie(userLogin.Email, false); } return RedirectToAction("Index","Home"); }
public UserAccount Add(UserAccount item) { //Create a new item var user = new UserAccount() { UserName = item.UserName, Email = item.Email, Password = item.Password, PasswordHint = item.PasswordHint, Active = true }; _lolDBContext.UserAccounts.Add(user); _lolDBContext.SaveChanges(); return user; }
public ActionResult RegisterUser(UserAccount userAccount, string confirmPassword) { //Check if user already exists UserAccount checkUser = _userManager.GetOneByEmail(userAccount.Email); if (checkUser != null) { //A account with this email already exists message return View("Login"); } else { //Make sure passwords match then hash them if (confirmPassword == userAccount.Password) { //Hash the password userAccount.Password = _userManager.GetHashedPassword(userAccount.Password); //Add new user _userManager.Add(userAccount); //If User was successfully added return the user to the login screen return View("Login"); } else { //Message that passwords dont match return View("Register"); } } }
public bool LogInUser(UserAccount user) { UserAccount checkUser = GetOneByEmail(user.Email); if (checkUser == null) { return false; } else { //Hash the passed in password and check if they match string checkPassword = GetHashedPassword(user.Password); if (checkPassword == checkUser.Password) { return true; } else { return false; } } }
public UserAccount EditById(UserAccount item, int id) { throw new NotImplementedException(); }