Exemplo n.º 1
0
        public PartialViewResult SignUp(SignUpModel signUpModel)
        {
            if (ModelState.IsValid)
            {
                ValidateSignUpModel(signUpModel);
            }

            if (ModelState.IsValid)
            {
                User user = new User
                {
                    Email = signUpModel.Email,
                    First_Name = signUpModel.FirstName,
                    Last_Name = signUpModel.LastName,
                    Username = signUpModel.Username,
                    Password = BCrypt.Net.BCrypt.HashString(signUpModel.Password),
                    IsManager = signUpModel.Username == ManagerName
                };

                _userBlo.AddUser(user);

                Authorize(user);
            }

            return PartialView("_SignUp");
        }
Exemplo n.º 2
0
 private void ValidateSignUpModel(SignUpModel signUpModel)
 {
     if (_userBlo.UserExists(signUpModel.Username))
     {
         ModelState.AddModelError("Username", "Sorry! This username already exists");
     }
 }