Ensure that boolean params in the API are parsed for truthiness (#6575)
Use Rails smart boolean cast to account for values such as "f", "0", "false", etc. Previously, if a param was present in the request, it would count as true.
This commit is contained in:
parent
47bdb9b33b
commit
fce8464077
7 changed files with 13 additions and 17 deletions
|
@ -51,6 +51,10 @@ class Api::BaseController < ApplicationController
|
|||
[params[:limit].to_i.abs, default_limit * 2].min
|
||||
end
|
||||
|
||||
def truthy_param?(key)
|
||||
ActiveModel::Type::Boolean.new.cast(params[key])
|
||||
end
|
||||
|
||||
def current_resource_owner
|
||||
@current_user ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue