diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/services/resource_access_tokens/create_service.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/services/resource_access_tokens/create_service.rb')
-rw-r--r-- | app/services/resource_access_tokens/create_service.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/services/resource_access_tokens/create_service.rb b/app/services/resource_access_tokens/create_service.rb index 70e09be9407..36858f33b49 100644 --- a/app/services/resource_access_tokens/create_service.rb +++ b/app/services/resource_access_tokens/create_service.rb @@ -10,7 +10,7 @@ module ResourceAccessTokens end def execute - return error("User does not have permission to create #{resource_type} Access Token") unless has_permission_to_create? + return error("User does not have permission to create #{resource_type} access token") unless has_permission_to_create? user = create_user @@ -26,6 +26,7 @@ module ResourceAccessTokens token_response = create_personal_access_token(user) if token_response.success? + log_event(token_response.payload[:personal_access_token]) success(token_response.payload[:personal_access_token]) else delete_failed_user(user) @@ -105,6 +106,10 @@ module ResourceAccessTokens resource.add_user(user, :maintainer, expires_at: params[:expires_at]) end + def log_event(token) + ::Gitlab::AppLogger.info "PROJECT ACCESS TOKEN CREATION: created_by: #{current_user.username}, project_id: #{resource.id}, token_user: #{token.user.name}, token_id: #{token.id}" + end + def error(message) ServiceResponse.error(message: message) end @@ -114,3 +119,5 @@ module ResourceAccessTokens end end end + +ResourceAccessTokens::CreateService.prepend_if_ee('EE::ResourceAccessTokens::CreateService') |