Module: DeviseJwtAuth::Concerns::ResourceFinder
- Extended by:
- ActiveSupport::Concern
- Includes:
- DeviseJwtAuth::Controllers::Helpers
- Included in:
- SetUserByToken
- Defined in:
- app/controllers/devise_jwt_auth/concerns/resource_finder.rb
Instance Method Summary collapse
- #find_resource(field, value) ⇒ Object
- #get_case_insensitive_field_from_resource_params(field) ⇒ Object
- #provider ⇒ Object
- #resource_class(m = nil) ⇒ Object
Methods included from DeviseJwtAuth::Controllers::Helpers
Instance Method Details
#find_resource(field, value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/devise_jwt_auth/concerns/resource_finder.rb', line 18 def find_resource(field, value) @resource = if resource_class.try(:connection_db_config).try(:[], :adapter).try(:include?, 'mysql') # fix for mysql default case insensitivity resource_class.where("BINARY #{field} = ? AND provider= ?", value, provider).first else resource_class.dta_find_by(field => value, 'provider' => provider) end end |
#get_case_insensitive_field_from_resource_params(field) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/devise_jwt_auth/concerns/resource_finder.rb', line 7 def get_case_insensitive_field_from_resource_params(field) # honor Devise configuration for case_insensitive keys q_value = resource_params[field.to_sym] q_value.downcase! if resource_class.case_insensitive_keys.include?(field.to_sym) q_value.strip! if resource_class.strip_whitespace_keys.include?(field.to_sym) q_value end |
#provider ⇒ Object
37 38 39 |
# File 'app/controllers/devise_jwt_auth/concerns/resource_finder.rb', line 37 def provider 'email' end |
#resource_class(m = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/devise_jwt_auth/concerns/resource_finder.rb', line 27 def resource_class(m = nil) mapping = if m Devise.mappings[m] else Devise.mappings[resource_name] || Devise.mappings.values.first end mapping.to end |