Class: SnfCore::TokenService
- Inherits:
-
Object
- Object
- SnfCore::TokenService
- Defined in:
- app/services/snf_core/token_service.rb
Instance Method Summary collapse
Instance Method Details
#decode(token) ⇒ Object
9 10 11 12 13 14 |
# File 'app/services/snf_core/token_service.rb', line 9 def decode(token) body = JWT.decode(token, ENV["SECRET_KEY_BASE"] || "secret_key_base")[0] HashWithIndifferentAccess.new body rescue JWT::DecodeError, JSON::ParserError => e raise JWT::DecodeError.new("Invalid token") end |
#encode(payload) ⇒ Object
5 6 7 |
# File 'app/services/snf_core/token_service.rb', line 5 def encode(payload) JWT.encode(payload, ENV["SECRET_KEY_BASE"] || "secret_key_base") end |