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-11 12:50:51 +0200
commitede46e60bf4d206f39dfa28edd479393a15a0630 (patch)
tree2b7137d1a164d571275a98ddb5d44a52089c5170
parente646439e9fa522c3c04989f7c1d4e0f7261d920b (diff)
downloadgitlab-ce-ede46e60bf4d206f39dfa28edd479393a15a0630.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 Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--CHANGELOG3
-rw-r--r--lib/api/helpers.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f510ef2f672..c6c0670d365 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
-v 8.12.5 (unreleased)
+v 8.12.5
+ - Switch from request to env in ::API::Helpers. !6615
v 8.12.4
- Fix "Copy to clipboard" tooltip to say "Copied!" when clipboard button is clicked. !6294 (lukehowell)
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