Module: RailsJwtAuth::Authenticatable::ClassMethods
- Defined in:
- app/models/concerns/rails_jwt_auth/authenticatable.rb
Instance Method Summary collapse
Instance Method Details
#from_token_payload(payload) ⇒ Object
120 121 122 123 124 125 126 |
# File 'app/models/concerns/rails_jwt_auth/authenticatable.rb', line 120 def from_token_payload(payload) if RailsJwtAuth.simultaneous_sessions > 0 get_by_token(payload['auth_token']) else where(id: payload['id']).first end end |
#get_by_token(token) ⇒ Object
128 129 130 131 132 133 134 |
# File 'app/models/concerns/rails_jwt_auth/authenticatable.rb', line 128 def get_by_token(token) if defined?(Mongoid) && ancestors.include?(Mongoid::Document) where(auth_tokens: token).first elsif defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base) where('auth_tokens like ?', "%#{token}%").first end end |