summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-19 18:26:15 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-19 18:26:15 +0800
commit4bf59f87b321d59de665a0100fed9114f4b747ea (patch)
tree548628a91be85631ac3b3bd8ec85c484ee70d707 /lib/api/helpers.rb
parente485b3f6ad3c220655e4aa909d93bca7a4ae6afc (diff)
parenta50cd9eb4b4392004e47e57b2fa37c12def5827f (diff)
downloadgitlab-ce-4bf59f87b321d59de665a0100fed9114f4b747ea.tar.gz
Merge remote-tracking branch 'upstream/master' into fix-forbidden-for-build-api-for-deleted-project
* upstream/master: (333 commits) Fix typo Always use `fixture_file_upload` helper to upload files in tests. Add CHANGELOG Move admin application spinach test to rspec Move admin deploy keys spinach test to rspec Fix rubocop failures Store mattermost_url in settings Improve Mattermost Session specs Ensure the session is destroyed Improve session tests Setup mattermost session Fix query in Projects::ProjectMembersController to fetch members Improve test for sort dropdown on members page Fix sort dropdown alignment Undo changes on members search button stylesheet Use factories to create project/group membership on specs Remove unused id from shared members sort dropdown Fix sort functionality on project/group members to return invited users Refactor MembersHelper#filter_group_project_member_path Remove unnecessary curly braces from sort dropdown partial ...
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb15
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 746849ef4c0..4be659fc20b 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -2,8 +2,6 @@ module API
module Helpers
include Gitlab::Utils
- PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN"
- PRIVATE_TOKEN_PARAM = :private_token
SUDO_HEADER = "HTTP_SUDO"
SUDO_PARAM = :sudo
@@ -308,7 +306,7 @@ module API
private
def private_token
- params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]
+ params[APIGuard::PRIVATE_TOKEN_PARAM] || env[APIGuard::PRIVATE_TOKEN_HEADER]
end
def warden
@@ -323,18 +321,11 @@ module API
warden.try(:authenticate) if %w[GET HEAD].include?(env['REQUEST_METHOD'])
end
- def find_user_by_private_token
- token = private_token
- return nil unless token.present?
-
- User.find_by_authentication_token(token) || User.find_by_personal_access_token(token)
- end
-
def initial_current_user
return @initial_current_user if defined?(@initial_current_user)
- @initial_current_user ||= find_user_by_private_token
- @initial_current_user ||= doorkeeper_guard
+ @initial_current_user ||= find_user_by_private_token(scopes: @scopes)
+ @initial_current_user ||= doorkeeper_guard(scopes: @scopes)
@initial_current_user ||= find_user_from_warden
unless @initial_current_user && Gitlab::UserAccess.new(@initial_current_user).allowed?