public virtual async Task <IdentityResult> ChangePasswordAsync(TUser user, string newPassword)
        {
            var result = await PasswordValidator.ValidateAsync(newPassword);

            if (!result.Succeeded)
            {
                return(result);
            }

            await CodeZeroStore.SetPasswordHashAsync(user, PasswordHasher.HashPassword(newPassword));

            return(IdentityResult.Success);
        }
Пример #2
0
        public virtual async Task <IdentityResult> ChangePasswordAsync(TUser user, string newPassword)
        {
            var errors = new List <IdentityError>();

            foreach (var validator in PasswordValidators)
            {
                var validationResult = await validator.ValidateAsync(this, user, newPassword);

                if (!validationResult.Succeeded)
                {
                    errors.AddRange(validationResult.Errors);
                }
            }

            if (errors.Any())
            {
                return(IdentityResult.Failed(errors.ToArray()));
            }

            await CodeZeroStore.SetPasswordHashAsync(user, PasswordHasher.HashPassword(user, newPassword));

            return(IdentityResult.Success);
        }