Not every user is equal
Your notes app has real users. Sign up, log in, and user-scoped notes all work. But every user is equal. Alice can't see Bob's notes, and Bob can't see Alice's. That's the point of user-scoped data.
But what if you need to see everything? What if you need to know how many users signed up, what notes they created, or delete something inappropriate? Right now, the only way to check is to open the database directly.
You need an admin — a user who can see all data and take actions that regular users can't.
Member vs admin
The idea is simple: two experiences in one app. Regular users (members) see only their own data at /app. Admins see everything at /admin — all users, all notes, and controls to manage them.
Same login flow. Same app. Different access based on one field in the database.
The approach
You won't build a separate admin app or install a library. You'll:
- Add a role column to the users table —
nullmeans member,'admin'means admin - Create a seed script to promote a user to admin
- Build a
requireAdminhelper that gates routes and actions - Add an
/adminroute tree with its own layout and pages
Here's the plan
- Add roles to users — Schema change, migration, seed script, and access helper
- Build the admin view — A dashboard showing all users and all notes
- Add admin actions — Delete any note, with confirmation and server-side guards
- Wrap up — Test both views and save your progress
By the end, you'll log in as a member and see only your data, then switch to an admin account and see everything. Let's start with the role column.