Last active
March 27, 2017 10:56
-
-
Save samueljmurray/3df66e25cb34f81d028eefcaa051be50 to your computer and use it in GitHub Desktop.
Guardian serializer
This file contains hidden or 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 YayCorp.GuardianSerializer do | |
| @behaviour Guardian.Serializer | |
| alias YayCorp.{Repo, UserAuth} | |
| def for_token(user_auth = %UserAuth{}), do: { :ok, "UserAuth:#{user_auth.id}" } | |
| def for_token(_), do: { :error, "Unknown resource type" } | |
| def from_token("UserAuth:" <> id), do: { :ok, Repo.get(UserAuth, 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