summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-07 09:17:35 +0000
committerRémy Coutable <remy@rymai.me>2016-10-07 09:17:35 +0000
commitb58ea12aa9b7ba9f3a8bcdfce32cb775ba05999a (patch)
treeadfd213830826c2a1a31c449b08264fa457a6399
parenta17412f0aa9ef9c99a5c136906ea8a585326c27d (diff)
parent86c0c0869dd4b9de301822a7d598bc4528604e5a (diff)
downloadgitlab-ce-b58ea12aa9b7ba9f3a8bcdfce32cb775ba05999a.tar.gz
Merge branch '22820-api-use-env-not-request-in-helpers' into 'master'
Resolve "NameError: undefined local variable or method `request' for #<Grape::Middleware::Error:0x007fc990..." ## What does this MR do? Switches from `request` to `env` in an API helper method as the helpers are included in contexts lacking `request`. ## Are there points in the code the reviewer needs to double check? I couldn't build a reproducer for this. Closes #22820 See merge request !6615
-rw-r--r--lib/api/helpers.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 8b8c4eb4d46..281a8f13531 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -25,7 +25,7 @@ module API
# Until CSRF protection is added to the API, disallow this method for
# state-changing endpoints
def find_user_from_warden
- warden.try(:authenticate) if request.get? || request.head?
+ warden.try(:authenticate) if %w[GET HEAD].include?(env['REQUEST_METHOD'])
end
def find_user_by_private_token