API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

json_web_token.rb 336B

12345678910111213
  1. class JsonWebToken
  2. SECRET_KEY = Rails.application.credentials.secret_key_base.to_s
  3. def self.encode(payload, exp = 24.hours.from_now)
  4. payload[:exp] = exp.to_i
  5. JWT.encode(payload, SECRET_KEY)
  6. end
  7. def self.decode(token)
  8. decoded = JWT.decode(token, SECRET_KEY).first
  9. HashWithIndifferentAccess.new decoded
  10. end
  11. end