Guardian.Plug.ErrorHandler behaviour (Guardian v2.4.0)
View SourceOptional Behaviour for creating error handlers for Guardian.Plug.Pipeline.
Error handler
When using plugs, you'll need to specify an error handler module.
The error_handler module requires an auth_error function that receives the conn,
the reason tuple and the options.
defmodule MyApp.AuthErrorHandler do
@behaviour Guardian.Plug.ErrorHandler
@impl Guardian.Plug.ErrorHandler
def auth_error(conn, {type, reason}, opts) do
...
end
endBy default, Guardian will emit types of:
:unauthorized:invalid_token:already_authenticated:no_resource_found
Summary
Callbacks
@callback auth_error( conn :: Plug.Conn.t(), {type :: atom(), reason :: atom()}, opts :: Guardian.options() ) :: Plug.Conn.t()