Exemple #1
0
        /// <summary>
        /// Creates a new user and saves their email in session.
        /// </summary>
        /// <returns></returns>
        public bool Register(string displayName, string email, string password, string role)
        {
            bool result       = false;
            var  hashProvider = new HashProvider();
            var  passwordHash = hashProvider.HashPassword(password);

            var user = new Users
            {
                DisplayName = displayName,
                Email       = email,
                Password    = passwordHash.Password,
                Salt        = passwordHash.Salt,
                Role        = role
            };

            result = userDAL.CreateUser(user);
            Session.SetString(SessionKey, user.Email);
            return(result);
        }
        public bool Register(string displayName, string email, string password, string role)
        {
            if (usersDAL.DoesEmailAlreadyExist(email))
            {
                return(false);
            }

            var hashProvider = new HashProvider();
            var passwordHash = hashProvider.HashPassword(password);

            var user = new User
            {
                DisplayName = displayName,
                Email       = email,
                Password    = passwordHash.Password,
                Salt        = passwordHash.Salt,
                Role        = role
            };

            bool result = usersDAL.CreateUser(user);

            return(result);
        }