Packages

Adds helpful extras to Guardian like default mailer support, as well as out of the box controllers and routes

Current section

Files

Jump to
sentinel lib sentinel serializers guardian_serializers.ex
Raw

lib/sentinel/serializers/guardian_serializers.ex

defmodule Sentinel.GuardianSerializer do
@behaviour Guardian.Serializer
alias Sentinel.Util
alias Sentinel.UserHelper
def for_token(user), do: { :ok, "User:#{user.id}" }
def for_token(_), do: { :error, "Unknown resource type" }
def from_token("User:" <> id), do: { :ok, Util.repo.get(UserHelper.model, id) }
def from_token(_), do: { :error, "Unknown resource type" }
end