Users & Auth
This commit is contained in:
1 parent
904a071fc0
commit
8a7b3d8ae0
26 files changed
+663
-14
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class JsonWebToken
|
||||
class << self
|
||||
def encode(payload, exp = 24.hours.from_now)
|
||||
payload[:exp] = exp.to_i
|
||||
JWT.encode(payload, ENV['jwt'])
|
||||
end
|
||||
|
||||
def decode(token)
|
||||
body = JWT.decode(token, ENV['jwt'])[0]
|
||||
HashWithIndifferentAccess.new body
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user