bodyguard v0.6.0 Bodyguard.ViewHelpers

Convenience functions for view authorization.

Summary

Functions

Returns a boolean indicating authorization status for a particular resource

Functions

can?(conn_or_user, action, resource, opts \\ [])
can?(Plug.Conn.t | term, atom, term, keyword) :: boolean

Returns a boolean indicating authorization status for a particular resource.

This is basically a thin wrapper around Bodyguard.authorized?/4, except the first argument is more flexible, and this function always returns a boolean.

The first argument may be either a user model or a Plug.Conn out of which the user model will be extracted – see Bodyguard.Controller.get_current_user/1.