Module: ActiveRecord::Jwt::Decoder::ClassMethods
- Defined in:
- lib/activerecord-jwt/decoder.rb
Instance Method Summary collapse
Instance Method Details
#decode_jwt(jwt) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/activerecord-jwt/decoder.rb', line 11 def decode_jwt(jwt) payload, header = JWT.decode(jwt, ActiveRecord::Jwt::Decoder.configuration.key, true, ActiveRecord::Jwt::Decoder.configuration.) payload_valid?(payload) { payload: payload, header: header } rescue JWT::DecodeError => e raise ActiveRecord::Jwt::InvalidError.new(e) end |
#find_authenticated_jwt(jwt) ⇒ Object
6 7 8 9 |
# File 'lib/activerecord-jwt/decoder.rb', line 6 def find_authenticated_jwt(jwt) decoded_jwt = decode_jwt(jwt) self.find_by(ActiveRecord::Jwt::Decoder.configuration.sub => decoded_jwt[:payload]['sub']) end |