{"action":"created","issue":{"url":"https://api.github.com/repos/ueberauth/guardian/issues/78","repository_url":"https://api.github.com/repos/ueberauth/guardian","labels_url":"https://api.github.com/repos/ueberauth/guardian/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/ueberauth/guardian/issues/78/comments","events_url":"https://api.github.com/repos/ueberauth/guardian/issues/78/events","html_url":"https://github.com/ueberauth/guardian/issues/78","id":124430746,"number":78,"title":"Handling Errors in LoadResource","user":{"login":"joshwlewis","id":917672,"avatar_url":"https://avatars.githubusercontent.com/u/917672?v=3","gravatar_id":"","url":"https://api.github.com/users/joshwlewis","html_url":"https://github.com/joshwlewis","followers_url":"https://api.github.com/users/joshwlewis/followers","following_url":"https://api.github.com/users/joshwlewis/following{/other_user}","gists_url":"https://api.github.com/users/joshwlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwlewis/subscriptions","organizations_url":"https://api.github.com/users/joshwlewis/orgs","repos_url":"https://api.github.com/users/joshwlewis/repos","events_url":"https://api.github.com/users/joshwlewis/events{/privacy}","received_events_url":"https://api.github.com/users/joshwlewis/received_events","type":"User","site_admin":false},"labels":[{"id":225298405,"url":"https://api.github.com/repos/ueberauth/guardian/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2015-12-31T04:15:58Z","updated_at":"2016-12-10T16:01:16Z","closed_at":null,"body":"Hi y'all,\n\nJust came across some unexpected functionality:\n\n``` elixir\ndefmodule MyApp.TokenSerializer do\n  @behaviour Guardian.Serializer\n  alias MyApp.Repo\n  alias MyApp.User\n\n  ...\n\n  def from_token(id) do\n    case user = Repo.get(User, id) do\n      %User{} ->\n        {:ok, user}\n      nil ->\n        {:error, \"Unknown resource\"}\n    end\n  end\nend\n```\n\nMy naive impression was that that returning an error here would cause Guardian to abort the request in some fashion. However, the error is swallowed up [here](https://github.com/ueberauth/guardian/blob/master/lib/guardian/plug/load_resource.ex#L29).\n\nI'll likely implement my own plug to verify that the `current_resource` is not nil for now, but I thought it might be nice if Guardian provided something similar. Two ideas:\n- Plug.LoadResource could call the `unauthenticated` method on the handler when the serializer returns an error\n- A new plug like (Plug.EnsureResource?) that calls the `unauthenticated` method on the handler when the serializer returns an error\n\nI'm happy to take a stab at a PR if you like either idea.\n"},"comment":{"url":"https://api.github.com/repos/ueberauth/guardian/issues/comments/266218241","html_url":"https://github.com/ueberauth/guardian/issues/78#issuecomment-266218241","issue_url":"https://api.github.com/repos/ueberauth/guardian/issues/78","id":266218241,"user":{"login":"steffenix","id":2143646,"avatar_url":"https://avatars.githubusercontent.com/u/2143646?v=3","gravatar_id":"","url":"https://api.github.com/users/steffenix","html_url":"https://github.com/steffenix","followers_url":"https://api.github.com/users/steffenix/followers","following_url":"https://api.github.com/users/steffenix/following{/other_user}","gists_url":"https://api.github.com/users/steffenix/gists{/gist_id}","starred_url":"https://api.github.com/users/steffenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steffenix/subscriptions","organizations_url":"https://api.github.com/users/steffenix/orgs","repos_url":"https://api.github.com/users/steffenix/repos","events_url":"https://api.github.com/users/steffenix/events{/privacy}","received_events_url":"https://api.github.com/users/steffenix/received_events","type":"User","site_admin":false},"created_at":"2016-12-10T16:01:16Z","updated_at":"2016-12-10T16:01:16Z","body":"Did you guys found a way to do it?"}}
{"actor":{"display_login":"steffenix"}}