Manage Users
The Manage Users page allows administrators to view all registered users, search for specific accounts, and change user roles. This is essential for managing permissions and granting administrative or moderation privileges.
Access this page by navigating to /admin/users after logging in with an account that has the admin role.
Overview
This page provides a table‑based interface for user management, with real‑time data from Convex. Key features include:
- User table – Displays email, Clerk ID, current role, and registration date.
- Search – Filter users by email or Clerk ID (debounced input).
- Role management – Change a user’s role using a dropdown (User, Moderator, Admin).
- Pagination – Navigate through pages when many users exist.
- Real‑time updates – Role changes are applied immediately via Convex mutations.
User Roles
Dirly supports three user roles, which control access to different parts of the application:
| Role | Permissions |
|---|---|
| User | Can browse tools, submit tools, upvote, and manage their own submissions. |
| Moderator | (Reserved for future use; currently same as User unless custom logic is added.) |
| Admin | Full access to all admin pages, can approve/reject tools, manage categories, users, and ad placements. |
The first admin must be created manually in the Convex dashboard by updating the role field in the users table. See Admin setup for instructions.
Page Components
Search Bar
A search input with a magnifying glass icon allows admins to filter users by email or Clerk ID. The search is debounced (500 ms) to reduce load, and the results update automatically. Pagination resets to the first page when searching.
User Table
The table displays the following columns:
| Column | Description |
|---|---|
| The user’s email address (if available; otherwise ”—”). | |
| Clerk ID | The unique identifier from Clerk (useful for debugging). |
| Role | The current role, shown as a badge (Admin badge is primary, others are secondary). |
| Registered | The date the user account was created in Convex. |
| Actions | A dropdown to change the user’s role (User, Moderator, Admin). |
Role Change Dropdown
- Click the dropdown to select a new role.
- After selection, a Convex mutation updates the role in the database.
- A toast notification confirms success or failure.
- The table updates automatically.
Pagination
If more than 10 users exist, pagination controls appear at the bottom of the table. You can navigate between pages, and the current page number is displayed.
Technical Details
- Data source: Convex query –
api.tools.getAllUsers(returns all users from theuserstable). - Mutation:
api.tools.updateUserRole– updates therolefield for a given user. - Search: Client‑side filtering on email and Clerk ID after the data is loaded. For very large user bases, you may consider server‑side filtering, but the current implementation works well for typical directory sizes.
- Pagination: Client‑side pagination of filtered results.
- Access control: Only users with
role === "admin"can view this page. The component checkscurrentUser.roleand denies access with a “Access Denied” message if not admin.
Usage Tips
- Use the search bar to quickly locate a specific user by their email address or Clerk ID.
- Be cautious when granting admin privileges – only promote trusted users.
- If you need to add a moderator role with limited permissions, you can extend the application’s authorization logic accordingly. Currently, the role is stored but not used beyond admin checks.
- To view more details about a user (e.g., their submissions, bookmarks), you may need to implement a user profile page or extend the table with links.
Troubleshooting
| Problem | Solution |
|---|---|
| User not appearing in the list | Ensure the user has successfully signed up and their Clerk ID is stored in the users table. Check the Convex dashboard for the users table. |
| Role change fails | Verify that the updateUserRole mutation exists and that you have permission to execute it. Check the browser console and Convex logs for errors. |
| Search does not find a user | Search matches email and Clerk ID exactly as stored. If the email is missing, use the Clerk ID. Also check that the debounced input has finished (500 ms delay). |
| Page loads slowly with many users | Consider implementing server‑side pagination and filtering for large user bases. |
Conclusion
The Manage Users page gives administrators full control over user roles in Dirly. With search, pagination, and a simple role change interface, you can efficiently manage permissions and keep your directory secure.
For more advanced user management (e.g., viewing submission history, resetting passwords), refer to the Clerk Dashboard or consider extending the application with additional features.