Skip to content

Conversation

@Raindancer118
Copy link

This pull request introduces a comprehensive set of changes to support admin functionality in the backend. It adds an is_admin field to the User model, implements admin-only API endpoints for user management, and enforces admin access via middleware. The changes include new handlers for admin operations, route setup, and logic to seed an initial admin user.

Admin API and Access Control:

  • Added AdminHandler in backend/handlers/admin.go with endpoints for dashboard stats, user listing/search, user promotion to admin, user deletion, verification, update, and password reset. All endpoints require admin authentication and password confirmation for sensitive actions.
  • Introduced AdminMiddleware in backend/middleware/auth.go to restrict access to admin routes, ensuring only authenticated admin users can access these endpoints.
  • Registered new admin routes in backend/main.go under /v1/admin, applying both authentication and admin middleware. [1] [2]

User Model and API Enhancements:

  • Added IsAdmin boolean field to the User model in backend/models/models.go, and exposed it in the user API responses. [1] [2] [3]

Admin User Initialization:

  • Added a seedAdmin function in backend/main.go to create or update an initial admin user ([email protected]) with a default password and admin privileges.

Other Improvements:

  • Updated imports in backend/main.go to support new functionality (e.g., uuid, utils, models). [1] [2]
  • Added comments and error handling throughout the new admin logic for clarity and robustness.

These changes collectively provide a secure and robust foundation for admin operations in the application.

@FinnK04 FinnK04 changed the title Add Admin Dashboard Feat: Add Admin Dashboard Nov 28, 2025
@FinnK04 FinnK04 self-requested a review November 28, 2025 22:14
Copy link
Collaborator

@FinnK04 FinnK04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the backend, create a new folder containing all backend files so that they correspond to the new planned structure.

@FinnK04 FinnK04 marked this pull request as draft November 28, 2025 22:59
@FinnK04 FinnK04 marked this pull request as ready for review November 28, 2025 22:59
@FinnK04 FinnK04 self-requested a review November 29, 2025 10:33
Copy link
Collaborator

@FinnK04 FinnK04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the changes you made to your .env file to the .env.example file.
Then rebase your changes, squash them, and give them a meaningful name :)

@FinnK04 FinnK04 self-requested a review December 4, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants