Module: RailsJwtApi::Controllers::Authentication

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

Instance Method Summary collapse

Instance Method Details

#decode(token) ⇒ Object



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

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

#encode(payout, exp = RailsJwtApi.token_expiration) ⇒ Object

TODO refactor to allow users to ad there own expiration date



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

def encode(payout, exp = RailsJwtApi.token_expiration)
  payout[:exp] = exp.to_i
  JWT.encode(payout, RailsJwtApi.token_secret_key)
    
end