How do I test admin permissions?
Last checked 31 Aug 2026
Short answer
Log in as a non-admin account and try to reach every admin action directly (URLs, buttons, API calls) to confirm the server — not just the UI — blocks it.
Why UI-hiding isn't enough
Hiding an "Admin" menu item for regular users stops them clicking it, but it doesn't stop them reaching the same page by typing the URL, or calling the same database/edge function request directly. Real protection has to live in row-level security (RLS) policies and server-side checks, using a separate user_roles table — never a role column on the user's own profile row.
How to test properly
- Create a genuine non-admin test account.
- Try navigating directly to admin routes (e.g.
/admin,/dashboard/users) while logged in as that account — confirm you're blocked or redirected, not just that the nav link is hidden. - Try triggering admin-only actions the account shouldn't have — deleting another user, changing a role, viewing another user's private data — and confirm they fail server-side.
- Check what happens logged out entirely for the same routes and actions.
- Confirm a user cannot self-assign a role — e.g. by checking that role changes require an existing admin and go through server-side validation.
A prompt to verify this
Confirm that admin-only actions and routes are protected by a server-side check against the user_roles table, not just hidden in the UI. Show me where that check happens for each admin action.
What usually goes wrong
- Role checks written only in front-end React code (
if (user.role === 'admin')), which can be bypassed since the actual data request isn't restricted. - Roles stored as a column on the
profiles/userstable instead of a separateuser_rolestable — this is a known Lovable/Supabase RLS pitfall because a user can sometimes edit their own profile row. - Forgetting to test cross-account access — user A reading or editing user B's private data.
See also /questions/how-do-i-test-rls, the underlying mechanism that should be enforcing all of this.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I test forms?Submit every form with valid, invalid and empty data, confirm error messages appear, and check that submitted data actually lands where it should (database, inbox or integration).
- AnswerHow do I test mobile devices?Open the published site on a real phone (or use your browser's device toolbar as a fallback) and check layout, tap targets, forms and navigation at common breakpoints.
- AnswerHow do I test RLS?Try reading and writing data as a different logged-in user and as a logged-out visitor to confirm row-level security actually blocks what it should, rather than assuming the policy is correct.
- AnswerHow do I test SEO?Check that every page has a unique title and meta description, images have alt text, the site generates a sitemap, and preview the page as a search engine or social share would see it.