Exemplo n.º 1
0
        public int Register(UserDataObject user)
        {
            RegistrationValidator validator = new RegistrationValidator(userData);

            if (!validator.IsValid(user))
            {
                throw new RegistrationException(validator.ErrorCodes);
            }
            user.EncryptedPassword = IGenProtector.Encrypt(user.Password);
            return(userData.Add(user));
        }
        public void ResetPassword(int userId, string password, string repassword)
        {
            PasswordValidator passwordValidator = new PasswordValidator();

            if (!passwordValidator.IsValid(password, repassword))
            {
                throw new FormException(passwordValidator.ErrorCodes);
            }
            if (userId == 0)
            {
                throw new UnAuthorizedException();
            }
            string encryptedPassword = IGenProtector.Encrypt(password);

            userForgotPassword.ResetPassword(userId, encryptedPassword);
        }
        public void ResetPassword(string token, string password, string repassword)
        {
            if (!IsValidPasswordToken(token))
            {
                throw new PasswordTokenExpiredException();
            }

            PasswordValidator passwordValidator = new PasswordValidator();

            if (!passwordValidator.IsValid(password, repassword))
            {
                throw new FormException(passwordValidator.ErrorCodes);
            }
            string encryptedPassword = IGenProtector.Encrypt(password);

            userForgotPassword.ResetPassword(token, encryptedPassword);
        }