mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-10 09:02:50 +00:00
init
This commit is contained in:
14
lib/myapp/jwt.ex
Normal file
14
lib/myapp/jwt.ex
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule MyApp.JWT do
|
||||
alias MyApp.Guardian
|
||||
|
||||
# ~1 year
|
||||
defp tokenTTL(), do: {52, :weeks}
|
||||
|
||||
def get_jwt(user, claims) do
|
||||
case Guardian.encode_and_sign(user, claims, ttl: tokenTTL()) do
|
||||
{:ok, token, _claims} -> {:ok, token}
|
||||
{:error, _token, _claims} -> {:error, "JWT error"}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user