Module: HasJwtToken::Authenticatable::ClassMethods
- Defined in:
- lib/has_jwt_token/authenticatable.rb
Instance Method Summary collapse
Instance Method Details
#find_with_jwt(jwt_token) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/has_jwt_token/authenticatable.rb', line 8 def find_with_jwt(jwt_token) payload = decode!(jwt_token) find_by(authenticate_by => payload[authenticate_by]) &.tap { |model| model.token = model.encode } rescue JWT::DecodeError raise HasJwtToken::InvalidToken, 'Invalid token has been provided.' end |