Fix guardian db hook when refresh the access token

This commit is contained in:
Chocobozzz
2019-08-12 17:41:41 +02:00
parent 6d221212ef
commit ac1dab0fc0
5 changed files with 41 additions and 10 deletions

View File

@@ -253,13 +253,21 @@ defmodule Mobilizon.Users do
end
def generate_access_token(user) do
with {:ok, access_token, _claims} <- MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "access", ttl: {5, :seconds}) do
with {:ok, access_token, _claims} <-
MobilizonWeb.Guardian.encode_and_sign(user, %{},
token_type: "access",
ttl: {5, :seconds}
) do
{:ok, access_token}
end
end
def generate_refresh_token(user) do
with {:ok, refresh_token, _claims} <- MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "refresh", ttl: {30, :days}) do
with {:ok, refresh_token, _claims} <-
MobilizonWeb.Guardian.encode_and_sign(user, %{},
token_type: "refresh",
ttl: {30, :days}
) do
{:ok, refresh_token}
end
end