Class: EasyJwtAuth::TokenBuilder
- Inherits:
-
Object
- Object
- EasyJwtAuth::TokenBuilder
- Defined in:
- lib/easy_jwt_auth/token_builder.rb
Instance Method Summary collapse
- #build_token(id) ⇒ Object
-
#initialize ⇒ TokenBuilder
constructor
A new instance of TokenBuilder.
Constructor Details
#initialize ⇒ TokenBuilder
Returns a new instance of TokenBuilder.
3 4 5 6 7 |
# File 'lib/easy_jwt_auth/token_builder.rb', line 3 def initialize @algo = Config.algo @expiration = Config.expiration @secret = Config.secret end |
Instance Method Details
#build_token(id) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/easy_jwt_auth/token_builder.rb', line 9 def build_token(id) iat = Time.now.to_i exp = iat + expiration payload = { id: id, iat: iat, exp: exp } JWT.encode(payload, secret, algo) end |