Exemplo n.º 1
0
        public IHttpActionResult PostResetPassword(ResetPassword_ApiRequestCreateModel resetPasswordCreateModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var resetPassword = _userService.GetResetPasswordRequestByResetSecurity(resetPasswordCreateModel.ResetPasswordSecurity);

            if (resetPassword == null)
            {
                return(NotFound());
            }

            if (resetPassword.IdUser != resetPasswordCreateModel.IdUser)
            {
                return(BadRequest());
            }

            resetPassword.NewPassword = resetPasswordCreateModel.Password;

            resetPassword = _userService.ResetPassword(resetPassword);

            var resetPasswordModel = _mapper.Map <ResetPassword_ApiResponseModel>(resetPassword);

            return(Ok(resetPasswordModel));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> ResetPassword(ResetPassword_MvcViewModel resetPasswordModel)
        {
            var resetPasswordRequestModel = new ResetPassword_ApiRequestCreateModel
            {
                Password = resetPasswordModel.NewPassword,
                ResetPasswordSecurity = resetPasswordModel.ResetPasswordSecurity,
                IdUser = resetPasswordModel.IdUser
            };

            var resetPasswordRequest = CreateApiRequest($"api/users/{resetPasswordModel.IdUser}/password-reset", HttpMethodENUM.POST, "application/x-www-form-urlencoded");

            resetPasswordRequest.AddRequestBodyParameter(resetPasswordRequestModel);
            var resetPasswordResponse = await _apiRestClient.ExecuteAsync <ResetPassword_ApiResponseModel>(resetPasswordRequest);

            return(View("Index"));
        }