예제 #1
0
        public bool IsConfirmPasswordMatched(string password, string confirmPassword)
        {
            if (PasswordActions.PasswordsAreEqual(password, confirmPassword))
            {
                return(true);
            }

            throw new ConfirmPasswordNotMatchException();
        }
예제 #2
0
 private User GetUser(User findedUser, string password)
 {
     if (findedUser == null)
     {
         throw new UserNotExistException();
     }
     if (!PasswordActions.CheckPassword(password, findedUser))
     {
         throw new WrongPasswordForUserException();
     }
     return(findedUser);
 }
예제 #3
0
        private void RegistrateUser(PreRegistrateUser user)
        {
            string salt = PasswordActions.GenerateSalt();
            //create user
            var regUser = new User
            {
                CreateDate   = DateTime.Now,
                Email        = user.Email,
                Info         = CorrectInfo(user.Info),
                IsApproved   = true,
                Login        = user.Login,
                PasswordHash = PasswordActions.GetHashForPassword(user.Password, salt),
                PasswordSalt = salt,
                Role         = Roles.SimpleUser,
                UserId       = Guid.NewGuid()
            };

            using (var repo = ApplicationSettings.GetRepository())
            {
                repo.CreateUser(regUser);
                repo.SaveChanges();
            }
        }