Class: Comee::Core::TokenService

Inherits:
Object
  • Object
show all
Defined in:
app/services/comee/core/token_service.rb

Class Method Summary collapse

Class Method Details

.decode(token) ⇒ Object



8
9
10
# File 'app/services/comee/core/token_service.rb', line 8

def self.decode(token)
  JWT.decode(token, key, true, algorithm: "HS256").first
end

.issue(payload) ⇒ Object



4
5
6
# File 'app/services/comee/core/token_service.rb', line 4

def self.issue(payload)
  JWT.encode(payload, key, "HS256")
end

.keyObject



12
13
14
# File 'app/services/comee/core/token_service.rb', line 12

def self.key
  ENV["SECRET_KEY"] || Rails.application.credentials.secret_key_base
end