Packages

This is a CMS written in Elixir. Aims to be the great open-source ecommerce and/or startup solution for those who are searching for a performance and stability on top of modern technologies like React and Elixir.

Current section

Files

Jump to
lyn web models guardian_token.ex
Raw

web/models/guardian_token.ex

defmodule Lyn.GuardianToken do
use Lyn.Web, :model
alias Lyn.Repo
alias Lyn.GuardianSerializer
@primary_key {:jti, :string, []}
@derive {Phoenix.Param, key: :jti}
schema "guardian_tokens" do
field :aud, :string
field :iss, :string
field :sub, :string
field :exp, :integer
field :jwt, :string
field :claims, :map
timestamps
end
def for_user(user) do
case GuardianSerializer.for_token(user) do
{:ok, aud} ->
(from t in Lyn.GuardianToken, where: t.sub == ^aud)
|> Repo.all
_ -> []
end
end
end