Module: RailsJwt::Controllers::Authentication

Included in:
Helpers, UsersController
Defined in:
lib/rails_jwt/controllers/authentication.rb

Constant Summary collapse

SECRET_KEY =
ENV.fetch("RAILS_JWT_TOKEN", 'development')

Instance Method Summary collapse

Instance Method Details

#decode(token) ⇒ Object



13
14
15
16
# File 'lib/rails_jwt/controllers/authentication.rb', line 13

def decode(token)
  decode = JWT.decode(token, SECRET_KEY)[0]
  HashWithIndifferentAccess.new decode
end

#encode(payout, exp = 1.month.from_now) ⇒ Object

TODO refactor to allow users to ad there own expiration date



7
8
9
10
11
# File 'lib/rails_jwt/controllers/authentication.rb', line 7

def encode(payout, exp = 1.month.from_now)
  payout[:exp] = exp.to_i
  JWT.encode(payout, SECRET_KEY)
    
end