Openmaize.Authorize
Module to verify that users are authorized to access the requested pages / resources.
Authorization is based on user roles, and so you will need a role
entry
in your user model.
There are two options:
redirects
- if true, which is the default, redirect if authorized or if there is an error
check
- an external function, with an arity of 4, which can run further checks
- some example can be found in the Openmaize.IdCheck module
Examples
Call Authorize without any options:
Plug Openmaize.Authorize
Call Authorize without redirects:
Plug Openmaize.Authorize, redirects: false
Call Authorize and perform an extra check using the function extra_check
:
Plug Openmaize.Authorize, check: &extra_check/4
Summary↑
call(conn, opts) | Verify that the user is authorized to access the requested page / resource |
init(opts) | Callback implementation for |
Functions
Verify that the user is authorized to access the requested page / resource.
Callback implementation for c:Plug.init/1
.