Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

How do I create admin users?

Last checked 31 Aug 2026

Short answer

Add a `user_roles` table with an `admin` role, assign it to the specific user's ID, and check that role server-side (in RLS policies and any admin-only functions) rather than trusting a front-end flag.

The correct pattern

Never store "is this user an admin" as a boolean column on a profiles/users table — a user could potentially edit their own row. Instead:

  1. Create a separate user_roles table with columns like user_id and role (e.g. admin, moderator, user).
  2. Use a Postgres function (has_role(user_id, role)) checked inside RLS policies to gate admin-only reads/writes.
  3. Assign the admin role to a specific account by inserting a row — ask Lovable to do this for you, or do it via a one-off admin action once you're signed in as that user.

Set up a user_roles table with admin and user roles, and make my account (email: you@example.com) an admin.

How to promote a user to admin

  • Sign up normally with the account you want to be admin.
  • Ask Lovable: "Give the user with email you@example.com the admin role in user_roles."
  • Lovable Cloud users don't have direct database dashboard access, so always go through Lovable's chat to run this kind of one-off data change rather than looking for a Supabase dashboard.

What usually goes wrong

  • Putting role on the profile table, which a signed-in user can update via a normal profile-edit form, silently making themselves admin.
  • Checking the role only in the front end (hiding a button) without an RLS policy — the underlying data is still exposed to direct API calls.
  • Forgetting that RLS policies must reference the user_roles table via a security definer function to avoid recursive policy checks.

Once roles exist, restricting pages by role is covered in how-do-i-prevent-normal-users-accessing-admin-pages.

Sources

Was this answer helpful?

Related questions

Website made, maintained and hosted by PromptSites.com

PromptSites logo