Guardian v0.13.0 Guardian.Plug.LoadResource

Fetches the resource specified in a set of claims.

The current resource is loaded by calling from_token/1 on your Guardian.Serializer with the value of the sub claim. See the :serializer option for more details.

If the the resource is loaded successfully, it is accessible by calling Guardian.Plug.current_resource/2.

If there is no valid JWT in the request so far (Guardian.Plug.VerifySession / Guardian.Plug.VerifyHeader) did not find a valid token then nothing will occur, and Guardian.Plug.current_resource/2 will be nil.

Options

  • :serializer - The serializer to use to load the current resource from the subject claim of the token. Defaults to the result of Guardian.serializer/0.