IngotWeb.Plugs.RequireAuth (Ingot v0.1.0)
View SourcePlug to require authentication for routes.
Validates the session and assigns current_user to conn. Redirects to login page if authentication fails.
Usage
# In router
pipeline :authenticated do
plug IngotWeb.Plugs.RequireAuth
end
# With custom redirect
pipeline :authenticated do
plug IngotWeb.Plugs.RequireAuth, redirect_to: "/login"
endAssigns
On successful authentication, assigns the following to conn:
:current_user- Map containing user_id, email, and roles
Summary
Types
@type options() :: keyword()