authy v0.1.1 Authy.Controller.Helpers

These are behind-the-scenes methods for handling controller authorization. These are only exported because the macros need to call them from other modules, and we don’t want to clutter up controller modules with helper functions when Authy.Controller is imported. You probably don’t need to call these functions directly.

Summary

Functions

Returns an atom specifying the authorization status for the current controller action. Typically this is not called directly by the developer, only indirectly through the Authy.Controller.authorize/2 macro

Returns a resource scope for a given controller action. Typically this is not called directly by the developer, only indirectly through the Authy.Controller.scope/2 macro

Call the “not found” handler on the configured module. Raises a RuntimeError if that handler is not configured

Call the “unauthorized” handler on the configured module. Raises a RuntimeError if that handler is not configured

Functions

conn_authorization(conn, term, opts)

Returns an atom specifying the authorization status for the current controller action. Typically this is not called directly by the developer, only indirectly through the Authy.Controller.authorize/2 macro.

Available options:

  • nils: :unauthorized (default) or :not_found - action to take when resource is nil
  • action: atom - override the controller action picked up from conn
  • user: term - override the current user picked up from conn
  • policy: atom - override the policy determined from the term
conn_scope(conn, term, opts \\ [])

Returns a resource scope for a given controller action. Typically this is not called directly by the developer, only indirectly through the Authy.Controller.scope/2 macro.

Available options:

  • action: atom - override the controller action picked up from conn
  • user: term - override the current user picked up from conn
  • policy: atom - override the policy determined from the term
not_found!(conn)

Call the “not found” handler on the configured module. Raises a RuntimeError if that handler is not configured.

unauthorized!(conn)

Call the “unauthorized” handler on the configured module. Raises a RuntimeError if that handler is not configured.