@@ -1470,9 +1470,9 @@ public UserAccount updateUser(UpdateUserCmd updateUserCmd) {
14701470 logger .debug ("Updating user with Id: " + user .getUuid ());
14711471
14721472 validateAndUpdateApiAndSecretKeyIfNeeded (updateUserCmd , user );
1473+ validateAndUpdateUserApiKeyAccess (updateUserCmd , user );
14731474 Account account = retrieveAndValidateAccount (user );
14741475
1475- validateAndUpdateUserApiKeyAccess (updateUserCmd , user , account );
14761476 validateAndUpdateFirstNameIfNeeded (updateUserCmd , user );
14771477 validateAndUpdateLastNameIfNeeded (updateUserCmd , user );
14781478 validateAndUpdateUsernameIfNeeded (updateUserCmd , user , account );
@@ -1690,12 +1690,16 @@ protected void validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmd updateUser
16901690 user .setSecretKey (secretKey );
16911691 }
16921692
1693- protected void validateAndUpdateUserApiKeyAccess (UpdateUserCmd updateUserCmd , UserVO user , Account account ) {
1693+ protected void validateAndUpdateUserApiKeyAccess (UpdateUserCmd updateUserCmd , UserVO user ) {
16941694 if (updateUserCmd .getApiKeyAccess () != null ) {
16951695 try {
16961696 ApiConstants .ApiKeyAccess access = ApiConstants .ApiKeyAccess .valueOf (updateUserCmd .getApiKeyAccess ().toUpperCase ());
16971697 user .setApiKeyAccess (access .toBoolean ());
1698- ActionEventUtils .onActionEvent (user .getId (), account .getAccountId (), account .getDomainId (), EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the user to " + access .toString (), user .getId (), ApiCommandResourceType .User .toString ());
1698+ Long callingUserId = CallContext .current ().getCallingUserId ();
1699+ Account callingAccount = CallContext .current ().getCallingAccount ();
1700+ ActionEventUtils .onActionEvent (callingUserId , callingAccount .getAccountId (), callingAccount .getDomainId (),
1701+ EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the User to " + access .toString (),
1702+ user .getId (), ApiCommandResourceType .User .toString ());
16991703 } catch (IllegalArgumentException ex ) {
17001704 throw new InvalidParameterValueException ("ApiKeyAccess value can only be Enabled/Disabled/Inherit" );
17011705 }
@@ -1707,7 +1711,11 @@ protected void validateAndUpdateAccountApiKeyAccess(UpdateAccountCmd updateAccou
17071711 try {
17081712 ApiConstants .ApiKeyAccess access = ApiConstants .ApiKeyAccess .valueOf (updateAccountCmd .getApiKeyAccess ().toUpperCase ());
17091713 account .setApiKeyAccess (access .toBoolean ());
1710- ActionEventUtils .onActionEvent (User .UID_ADMIN , account .getAccountId (), account .getDomainId (), EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the account to " + access .toString (), account .getId (), ApiCommandResourceType .Account .toString ());
1714+ Long callingUserId = CallContext .current ().getCallingUserId ();
1715+ Account callingAccount = CallContext .current ().getCallingAccount ();
1716+ ActionEventUtils .onActionEvent (callingUserId , callingAccount .getAccountId (), callingAccount .getDomainId (),
1717+ EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the Account to " + access .toString (),
1718+ account .getId (), ApiCommandResourceType .Account .toString ());
17111719 } catch (IllegalArgumentException ex ) {
17121720 throw new InvalidParameterValueException ("ApiKeyAccess value can only be Enabled/Disabled/Inherit" );
17131721 }
0 commit comments