Commit b58ea12a 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
parents a17412f0 86c0c086
...@@ -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