class Commons::Authentication::JSONWebToken

Constants

SECRET_KEY

Public Class Methods

decode(token) click to toggle source
# File lib/commons/authentication/json_web_token.rb, line 11
def self.decode(token)
  decoded = JWT.decode(token, SECRET_KEY)[0]
  HashWithIndifferentAccess.new decoded
end
encode(payload, exp = 24.hours.from_now) click to toggle source
# File lib/commons/authentication/json_web_token.rb, line 6
def self.encode(payload, exp = 24.hours.from_now)
  payload[:expires_at] = exp.to_i
  JWT.encode(payload, SECRET_KEY)
end