Beispiel #1
0
        public async Task <ChangePassResultEnum> ChangePassword(CurrentUser user, ChangePassInfoDto changePassInfo)
        {
            UserEntity userEntity = await _userManager.FindByIdAsync(user.UserId);

            IdentityResult result = await _userManager.ChangePasswordAsync(userEntity, changePassInfo.CurrentPassword,
                                                                           changePassInfo.NewPassword);

            if (result.Succeeded)
            {
                return(ChangePassResultEnum.Success);
            }
            else if (result.Errors.Any(x => string.Equals(x.Code, "PasswordMismatch")))
            {
                return(ChangePassResultEnum.WrongCurrentPassword);
            }
            else
            {
                return(ChangePassResultEnum.Unknown);
            }
        }
Beispiel #2
0
 public async Task <ChangePassResultEnum> ChangePassword(ChangePassInfoDto changePassInfo)
 {
     Validate();
     return(await _accountService.ChangePassword(GetUser(), changePassInfo));
 }