Ejemplo n.º 1
0
        public async Task <IActionResult> ResetPasswordUser([FromBody] ResetPasswordCmd request)
        {
            try
            {
                var result = await _service.ResetPassword(request);

                return(Ok(result));
            }
            catch (BusinessLogicException ex)
            {
                return(BadRequest(new Response
                {
                    Status = false,
                    Message = ex.Message
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(new Response
                {
                    Status = false,
                    Message = ErrorMessages.UnkownError
                              //e.Message
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <Response> ResetPassword(ResetPasswordCmd request)
        {
            var user = await _userManager.FindByIdAsync(request.Id);

            if (user == null)
            {
                throw new BusinessLogicException("رکوردی با این مشخصات یافت نشد");
            }
            var userHashPassword = _userManager.PasswordHasher.HashPassword(user, request.NewPassword);

            user.PasswordHash = userHashPassword;

            var result = await _userManager.UpdateAsync(user);

            if (!result.Succeeded)
            {
                throw new Exception();
            }

            return(new Response
            {
                Status = true,
                Message = "success",
            });
        }