diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-09-03 09:35:21 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-09-03 09:35:21 +0200 |
commit | 2436631dea9264045d8694705a95d90c30b4057d (patch) | |
tree | 53c55f8c7ec7d4695d863585fe4dc8aba4527c84 /lib/api/internal.rb | |
parent | b3cd41b4014fa96780218f0f086de239731ec91a (diff) | |
parent | 2aaab34b67eb2a6593780eda33d501a715ef0c5f (diff) | |
download | gitlab-ce-refactor/ci-config-add-logical-validation.tar.gz |
Merge branch 'master' into refactor/ci-config-add-logical-validationrefactor/ci-config-add-logical-validation
* master: (414 commits)
Remove suggested colors hover underline
Fix markdown anchor icon interaction
Fix expiration date picker after update
Refactored code to rely less on IDs that could change
Move CHANGELOG entry for !5858 from 8.11 to 8.12
Hides merge request section in edit project when disabled
Fix a typo
Change minimum Unicorns required to two
Update memory requirements
Added `.term-bold` declaration.
Change the inline code to codeblocks for the new features doc guideline
Fix GitLab import button
Rename behaviour to behavior in bug issue template for consistency
Convert datetime coffeescript spec to ES6
Align add button on repository view
Update CHANGELOG with 8.11.4 entries.
removed null return - renamed 'placeTop' to 'placeProfileAvatarsToTop'
Refactor Ci::Build#raw_trace
Move CHANGELOG entry to a proper version
Change widths of content in MR pipeline tab
...
Conflicts:
lib/gitlab/ci/config/node/jobs.rb
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r-- | lib/api/internal.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 5b54c11ef62..6e6efece7c4 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -105,15 +105,19 @@ module API post '/two_factor_recovery_codes' do status 200 - key = Key.find(params[:key_id]) - user = key.user + key = Key.find_by(id: params[:key_id]) + + unless key + return { 'success' => false, 'message' => 'Could not find the given key' } + end - # Make sure this isn't a deploy key - unless key.type.nil? + if key.is_a?(DeployKey) return { success: false, message: 'Deploy keys cannot be used to retrieve recovery codes' } end - unless user.present? + user = key.user + + unless user return { success: false, message: 'Could not find a user for the given key' } end |