Sha256: f503bc0b47e526f85354653d5ea66a1d31e4496c5da10394c473838a3b986b72

Contents?: true

Size: 418 Bytes

Versions: 2

Compression:

Stored size: 418 Bytes

Contents

module Jobshop
  class JWTService
    HMAC_SECRET = "fixme"

    def self.encode(payload, exp = 24.hours.from_now)
      payload[:exp] = exp.to_i
      JWT.encode(payload, HMAC_SECRET)
    end

    def self.decode(token)
      body = JWT.decode(token, HMAC_SECRET)[0]
      HashWithIndifferentAccess.new body
    rescue JWT::DecodeError => e
      raise AuthorizationHandler::TokenInvalid, e.message
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jobshop-0.0.163 app/services/jobshop/jwt_service.rb
jobshop-0.0.157 app/services/jobshop/jwt_service.rb