Created
December 22, 2016 21:19
-
-
Save javierg/ab1fbab749dd58be23071a5f96f25a07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule GuardianSerializer do | |
@behaviour Guardian.Serializer | |
alias PhoenixUeberauthComeonin.Repo | |
def for_token(user = %User{}), do: { :ok, "User:#{user.id}" } | |
def for_token(_), do: { :error, "Unknown resource type" } | |
def from_token("User:" <> id), do: { :ok, Repo.get(User, id) } | |
def from_token(_), do: { :error, "Unknown resource type" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment