Sigra.Plug.RequireAuthenticated (Sigra v1.20.0)

Copy Markdown View Source

Authentication gate plug that halts unauthenticated requests.

This plug checks for conn.assigns.current_scope. If present, the request passes through unchanged. If absent (nil), the configured error handler is called with :unauthenticated and the connection is halted.

Options

Example

plug Sigra.Plug.RequireAuthenticated,
  error_handler: MyAppWeb.AuthErrorHandler

Summary

Functions

Check for authenticated user and halt if not present.

Initialize the plug with the given options.

Functions

call(conn, opts)

(since 0.1.0)

Check for authenticated user and halt if not present.

init(opts)

(since 0.1.0)

Initialize the plug with the given options.