@@ -1456,9 +1456,9 @@ public UserAccount updateUser(UpdateUserCmd updateUserCmd) {
14561456 logger .debug ("Updating user with Id: " + user .getUuid ());
14571457
14581458 validateAndUpdateApiAndSecretKeyIfNeeded (updateUserCmd , user );
1459+ validateAndUpdateUserApiKeyAccess (updateUserCmd , user );
14591460 Account account = retrieveAndValidateAccount (user );
14601461
1461- validateAndUpdateUserApiKeyAccess (updateUserCmd , user , account );
14621462 validateAndUpdateFirstNameIfNeeded (updateUserCmd , user );
14631463 validateAndUpdateLastNameIfNeeded (updateUserCmd , user );
14641464 validateAndUpdateUsernameIfNeeded (updateUserCmd , user , account );
@@ -1676,12 +1676,16 @@ protected void validateAndUpdateApiAndSecretKeyIfNeeded(UpdateUserCmd updateUser
16761676 user .setSecretKey (secretKey );
16771677 }
16781678
1679- protected void validateAndUpdateUserApiKeyAccess (UpdateUserCmd updateUserCmd , UserVO user , Account account ) {
1679+ protected void validateAndUpdateUserApiKeyAccess (UpdateUserCmd updateUserCmd , UserVO user ) {
16801680 if (updateUserCmd .getApiKeyAccess () != null ) {
16811681 try {
16821682 ApiConstants .ApiKeyAccess access = ApiConstants .ApiKeyAccess .valueOf (updateUserCmd .getApiKeyAccess ().toUpperCase ());
16831683 user .setApiKeyAccess (access .toBoolean ());
1684- 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 ());
1684+ Long callingUserId = CallContext .current ().getCallingUserId ();
1685+ Account callingAccount = CallContext .current ().getCallingAccount ();
1686+ ActionEventUtils .onActionEvent (callingUserId , callingAccount .getAccountId (), callingAccount .getDomainId (),
1687+ EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the User to " + access .toString (),
1688+ user .getId (), ApiCommandResourceType .User .toString ());
16851689 } catch (IllegalArgumentException ex ) {
16861690 throw new InvalidParameterValueException ("ApiKeyAccess value can only be Enabled/Disabled/Inherit" );
16871691 }
@@ -1693,7 +1697,11 @@ protected void validateAndUpdateAccountApiKeyAccess(UpdateAccountCmd updateAccou
16931697 try {
16941698 ApiConstants .ApiKeyAccess access = ApiConstants .ApiKeyAccess .valueOf (updateAccountCmd .getApiKeyAccess ().toUpperCase ());
16951699 account .setApiKeyAccess (access .toBoolean ());
1696- 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 ());
1700+ Long callingUserId = CallContext .current ().getCallingUserId ();
1701+ Account callingAccount = CallContext .current ().getCallingAccount ();
1702+ ActionEventUtils .onActionEvent (callingUserId , callingAccount .getAccountId (), callingAccount .getDomainId (),
1703+ EventTypes .API_KEY_ACCESS_UPDATE , "Api key access was changed for the Account to " + access .toString (),
1704+ account .getId (), ApiCommandResourceType .Account .toString ());
16971705 } catch (IllegalArgumentException ex ) {
16981706 throw new InvalidParameterValueException ("ApiKeyAccess value can only be Enabled/Disabled/Inherit" );
16991707 }
0 commit comments