diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /lib/api/internal/base.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'lib/api/internal/base.rb')
-rw-r--r-- | lib/api/internal/base.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index 17599c72243..ff687a57888 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -241,14 +241,16 @@ module API break { success: false, message: "Invalid token expiry date: '#{params[:expires_at]}'" } end - access_token = nil + result = ::PersonalAccessTokens::CreateService.new( + user, name: params[:name], scopes: params[:scopes], expires_at: expires_at + ).execute - ::Users::UpdateService.new(current_user, user: user).execute! do |user| - access_token = user.personal_access_tokens.create!( - name: params[:name], scopes: params[:scopes], expires_at: expires_at - ) + unless result.status == :success + break { success: false, message: "Failed to create token: #{result.message}" } end + access_token = result.payload[:personal_access_token] + { success: true, token: access_token.token, scopes: access_token.scopes, expires_at: access_token.expires_at } end |