示例#1
0
        async Task<CommonValidationResponse> ValidateRegistration(
            string email,
            string password,
            string phoneNumber,
            IAccountService accountService)
        {
            var commonValidationResponse = new CommonValidationResponse();
            var sharedValidation = new SharedValidation();
            var emailValidationResponse = await sharedValidation.IsValidEmailFormat(email, accountService);
            var passwordValidationResponse = sharedValidation.IsValidPassword(password);
            var phoneNumberValidationResponse = IsValidPhoneNumber(phoneNumber);

            commonValidationResponse.JoinValidationResponses(emailValidationResponse, passwordValidationResponse, phoneNumberValidationResponse);
            return commonValidationResponse;
        }
示例#2
0
        public CommonValidationResponse ChangePassword(string oldPassword, string newPassword)
        {
            var validationResponse = new CommonValidationResponse();
            string validationCategory = "password";
            if (!Cryptography.ValidatePassword(oldPassword, this.passwordHash))
            {
                validationResponse.AddErrorMessages(validationCategory, "The old password provided was not correct");
            }
            var sharedValidation = new SharedValidation();
            validationResponse.JoinValidationResponses(sharedValidation.IsValidPassword(newPassword));

            if (validationResponse.anyErrorMessages)
            {
                return validationResponse;
            }

            this.passwordHash = Cryptography.CreateHash(newPassword);

            return CommonValidationResponse.Ok();
        }