Example #1
0
        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");
        }
Example #2
0
        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;
        }
Example #3
0
        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");
                }

            }
        }
Example #4
0
        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;
                }

            }
        }
Example #5
0
 public UserAccount EditById(UserAccount item, int id)
 {
     throw new NotImplementedException();
 }