IngotWeb.Plugs.RequireRole (Ingot v0.1.0)
View SourcePlug to require specific role for routes.
Checks that the current user has the required role. Must be used after RequireAuth plug.
Usage
# In router
pipeline :admin_required do
plug IngotWeb.Plugs.RequireAuth
plug IngotWeb.Plugs.RequireRole, role: :admin
end
# With custom redirect
pipeline :labeler_required do
plug IngotWeb.Plugs.RequireAuth
plug IngotWeb.Plugs.RequireRole, role: :labeler, redirect_to: "/dashboard"
endRole Hierarchy
The :admin role grants all permissions. Users with admin role
will pass all role checks regardless of the required role.
Summary
Types
@type options() :: keyword()