How do I delete a user?
Last checked 31 Aug 2026
Short answer
Ask Lovable to add an admin action that deletes both the user's auth account and their related data (profile rows, uploads, etc.), since removing one without the other leaves orphaned records or broken references.
Why this needs care
Deleting "a user" usually means deleting from two places: the auth system (their login/session record) and your own database rows (profile, posts, orders). Delete only the auth record and you'll leave orphaned rows; delete only the profile row and they can often still log in.
How to do it
- Ask Lovable: "Add an admin action to delete a user completely — remove their auth account and cascade-delete their profile, posts and uploads."
- Use
ON DELETE CASCADEon foreign keys pointing at the user's ID where it makes sense, so related rows clean up automatically when the auth record goes. - For data you must keep for records (e.g. completed orders), anonymise instead of cascading — ask Lovable to null out personal fields rather than delete the row.
When an admin deletes a user, remove their auth account and all owned rows in profiles, posts and comments, but keep their past orders with personal details anonymised.
What usually goes wrong
- Deleting the profile row but not the auth account, so the person can still log in to a broken, empty account.
- No cascade set up, leaving foreign-key errors or orphaned rows referencing a user that no longer exists.
- Self-deletion: letting a user delete their own account without confirmation, or without checking they're not the last admin.
- Because Lovable Cloud users don't have direct dashboard access, always route deletions through an admin action Lovable builds, not a manual step you'd expect from a database dashboard.
Letting users delete their own account
If this is a self-service "delete my account" feature rather than an admin tool, say so explicitly when prompting — the confirmation flow and scope of what's deleted should usually differ.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I add password reset?Ask Lovable to add a "forgot password" flow — it uses Lovable Cloud's authentication to email a reset link and lets the user set a new password.
- AnswerHow do I add login to Lovable?Ask Lovable to add authentication — it enables Lovable Cloud (if not already on), then generates sign-up/login pages and wires them to email, Google, or other providers.
- AnswerHow do I create admin users?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.
- AnswerWhy does my app keep redirecting to login?This is almost always a session or route-guard bug: either the auth session isn't persisting, or a protected route checks auth state before it's loaded, so it bounces back to login even when signed in.
You might also need
- GuideHow to Create Protected PagesRestrict routes to signed-in users properly — including the server-side check most AI-generated guards miss.
- GuideHow to Add User Login to a Lovable ProjectSign-up, sign-in, sign-out and sessions — plus the settings people forget that break login on the live site.
- GuideHow to Add User Roles and PermissionsAdmin, editor and member roles done safely — stored separately from user profiles so they cannot be escalated.