Commit ede46e60 authored by Rémy Coutable's avatar Rémy Coutable

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: default avatarRémy Coutable <remy@rymai.me>
parent e646439e
Please view this file on the master branch, on stable branches it's out of date. 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 v 8.12.4
- Fix "Copy to clipboard" tooltip to say "Copied!" when clipboard button is clicked. !6294 (lukehowell) - Fix "Copy to clipboard" tooltip to say "Copied!" when clipboard button is clicked. !6294 (lukehowell)
......
...@@ -25,7 +25,7 @@ module API ...@@ -25,7 +25,7 @@ module API
# Until CSRF protection is added to the API, disallow this method for # Until CSRF protection is added to the API, disallow this method for
# state-changing endpoints # state-changing endpoints
def find_user_from_warden 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 end
def find_user_by_private_token def find_user_by_private_token
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment