예제 #1
0
        public IActionResult UpdatePassword(UpdatePasswordViewModel model)
        {
            ViewData[AccountConstants.SuccessPasswordUpdate] = false;
            if (ModelState.IsValid)
            {
                try
                {
                    var updateUserPasswordContract = new UpdateUserPasswordContract
                    {
                        NewPassword = model.Password,
                        OldPassword = model.OldPassword
                    };

                    var client = GetUserClient();
                    client.UpdateCurrentPassword(updateUserPasswordContract);
                    ViewData[AccountConstants.SuccessPasswordUpdate] = true;
                    return(PartialView("UserProfile/_UpdatePassword", null));
                }
                catch (HttpErrorCodeException e)
                {
                    AddErrors(e);
                }
                catch (MainServiceException e)
                {
                    AddErrors(e);
                }
            }

            return(PartialView("UserProfile/_UpdatePassword", model));
        }
예제 #2
0
 public IActionResult UpdateCurrentPassword([FromBody] UpdateUserPasswordContract data)
 {
     try
     {
         var userId = m_authenticationManager.GetCurrentUserId();
         m_userManager.UpdateUserPassword(userId, data);
         return(Ok());
     }
     catch (HttpErrorCodeException exception)
     {
         return(StatusCode(exception.StatusCode, exception.Message));
     }
 }
예제 #3
0
        public void UpdateUserPassword(int userId, UpdateUserPasswordContract data)
        {
            var userExternalId = GetUserExternalId(userId);

            var contract = new AuthChangePasswordContract
            {
                OriginalPassword = data.OldPassword,
                Password         = data.NewPassword
            };

            var client = m_communicationProvider.GetAuthUserApiClient();

            client.PasswordChangeAsync(userExternalId, contract).GetAwaiter().GetResult();
        }
예제 #4
0
        public void UpdateCurrentPassword(UpdateUserPasswordContract data)
        {
            try
            {
                //EnsureSecuredClient();
                m_client.Put <object>("user/current/password", data);
            }
            catch (HttpRequestException e)
            {
                if (m_logger.IsErrorEnabled())
                {
                    m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e);
                }

                throw;
            }
        }