Authenticationadvanced
Add Role-Based User Permissions
Creates a safe role system stored in its own table, with a role-check function used by your access rules and server actions.
When to use it
Admin and member roles
Lovable Prompt
Add a role-based permission system to this project. Requirements: - Create a dedicated roles table with a user reference and a role value of admin, editor or member. Do NOT store the role on the profiles table. - Create a security-definer function that returns whether a given user has a given role. - Use that function inside row level security policies so admins can manage all rows and members can only manage their own. - Add an admin-only area that re-checks the role server-side, not just in the interface. - Add a way for an existing admin to grant and revoke roles. Acceptance criteria: - A member account cannot load admin pages or admin data, even by typing the URL. - A member cannot change their own role. - Privileged server actions fail cleanly for non-admins. Do not change anything outside the permission system.
Why it works
It names where the role must be stored, forces a server-side check, and gives testable acceptance criteria rather than a vague request for "admin access".
Guides that use this prompt
TutorialAuthentication
How to Add User Roles and Permissions
Admin, editor and member roles done safely — stored separately from user profiles so they cannot be escalated.
advanced 11 minChecked 24 Aug 2026
TutorialAuthentication
How to Create Protected Pages
Restrict routes to signed-in users properly — including the server-side check most AI-generated guards miss.
intermediate 8 minChecked 24 Aug 2026
TutorialAuthentication
How to Add User Login to a Lovable Project
Sign-up, sign-in, sign-out and sessions — plus the settings people forget that break login on the live site.
beginner 10 minChecked 24 Aug 2026