We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Generates a complete authentication system for Phoenix applications using Phoenix's built-in phx.gen.auth
generator, extended with role-based access control, user profiles, and admin functionality. This feature provides a production-ready authentication foundation with minimal setup.
Key Benefits
Implementation Details
Uses Phoenix's mix phx.gen.auth
as the foundation, then extends the generated User schema with additional fields including role enum, profile information, and soft deletion support. The system includes custom changesets for profile updates separate from authentication changes, and implements automatic role assignment based on configuration.
Usage Example
# Update user profile without affecting authentication
{:ok, user} = Users.update_user(user, %{
name: "John Doe",
locale: "en",
timezone: "America/New_York"
})
# Role-based access in controllers
defp require_admin(conn, _opts) do
if conn.assigns.current_user.role in [:admin, :superuser] do
conn
else
# Handle unauthorized access
end
end
Configuration
Requires configuration in config.exs
to define admin emails and enable first-user promotion. The system supports embedding additional user data through the flexible data
field, and includes comprehensive test coverage for both authentication and profile management features.