Exemplo n.º 1
0
        public async Task <OperationResult> ChangeForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM)
        {
            var result = await _userRepository.UpdateForgotPassword(changeForgotPasswordVM);

            if (result.Succeeded)
            {
                await _context.SaveChangesAsync();

                return(OperationResult.Success);
            }
            else
            {
                return(OperationResult.InvalidPassword);
            }
        }
Exemplo n.º 2
0
        public async Task <IdentityResult> UpdateForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM)
        {
            ApplicationUser user = await _userManager.FindByEmailAsync(changeForgotPasswordVM.Email);

            IdentityResult result = IdentityResult.Failed();

            if (user != null)
            {
                var _passwordValidator = _httpContext.RequestServices.GetService(typeof(IPasswordValidator <ApplicationUser>)) as IPasswordValidator <ApplicationUser>;
                var _passwordHasher    = _httpContext.RequestServices.GetService(typeof(IPasswordHasher <ApplicationUser>)) as IPasswordHasher <ApplicationUser>;

                result = await _passwordValidator.ValidateAsync(_userManager, user, changeForgotPasswordVM.NewPassword);

                if (result.Succeeded)
                {
                    user.PasswordHash = _passwordHasher.HashPassword(user, changeForgotPasswordVM.NewPassword);
                    await _userManager.UpdateAsync(user);

                    await _context.SaveChangesAsync();
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public async Task <OperationResult> ChangeForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM)
        {
            await _userStorage.ChangeForgotPassword(changeForgotPasswordVM);

            return(OperationResult.Success);
        }
Exemplo n.º 4
0
        public async Task <OperationResult> ChangeForgotPassword([FromBody] ChangeForgotPasswordVM сhangeForgotPasswordVM)
        {
            var result = await _userBuilder.ChangeForgotPassword(сhangeForgotPasswordVM);

            return(result);
        }