EzAuth.Handler behaviour (EzAuth v0.1.0)

Copy Markdown View Source

Customizes HTTP responses after EzAuth actions.

Configure a handler with auth_routes(handler: MyAppWeb.AuthHandler) when your Phoenix app needs to add flashes, redirect somewhere specific, or render a custom response after an authentication action.

Summary

Callbacks

handle_failure(conn, event, reason)

(optional)
@callback handle_failure(
  conn :: struct(),
  event :: {atom(), atom()},
  reason :: term()
) :: struct()

handle_success(conn, event, user)

(optional)
@callback handle_success(
  conn :: struct(),
  event :: {atom(), atom()},
  user :: struct()
) :: struct()

Functions

maybe_invoke(conn, handler, fun, args)