Class: ZeusClient::V1::MultiplayerJWT

Inherits:
Object
  • Object
show all
Defined in:
lib/zeus/v1/client/multiplayer.rb

Class Method Summary collapse

Class Method Details

.decode(secret_key, token) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/zeus/v1/client/multiplayer.rb', line 110

def decode(secret_key, token)
    decoded = JWT.decode(token, secret_key)
    body = decoded[0]
    HashWithIndifferentAccess.new JSON.parse(body)
rescue Exception => e
    puts("ERROR DECODING TOKEN")
    puts(e.inspect)
    nil
end

.encode(secret_key, payload, exp = 6.months.from_now) ⇒ Object



104
105
106
107
108
# File 'lib/zeus/v1/client/multiplayer.rb', line 104

def encode(secret_key, payload, exp = 6.months.from_now)
    # payload[:exp] = exp.to_i
    payload = payload.to_json if payload.class != String
    JWT.encode(payload, secret_key)
end