Ejemplo n.º 1
0
        public async Task <ResponseBase> ChangePassword([FromBody] ChangePasswordRequest request)
        {
            var result = await UserManager
                         .ChangePasswordAsync(await GetCurrentUser(), request.CurrentPassword, request.NewPassword);

            if (result.Succeeded)
            {
                return(ResponseBase.OK);
            }

            throw ApiLogicException.Create(
                      InputParameterIncorrectResponse.Create(result.Errors));
        }
Ejemplo n.º 2
0
        public async Task <ResponseBase> ResetPassword([FromBody] ResetPasswordRequest request)
        {
            var userByMail = await UserManager.FindByEmailAsync(request.Email)
                             ?? throw ResponseStatusCode.UserNotFound.ToApiException();

            var result = await UserManager.ResetPasswordAsync(userByMail, request.Token, request.NewPassword);

            if (result.Succeeded)
            {
                return(ResponseBase.OK);
            }

            throw ApiLogicException.Create(
                      InputParameterIncorrectResponse.Create(result.Errors));
        }