-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: Add Admin Dashboard #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
FinnK04
left a comment
There was a problem hiding this 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.
…eset, explicit user field selection, and configurable initial admin password.
FinnK04
left a comment
There was a problem hiding this 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 :)
This pull request introduces a comprehensive set of changes to support admin functionality in the backend. It adds an
is_adminfield to theUsermodel, 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:
AdminHandlerinbackend/handlers/admin.gowith 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.AdminMiddlewareinbackend/middleware/auth.goto restrict access to admin routes, ensuring only authenticated admin users can access these endpoints.backend/main.gounder/v1/admin, applying both authentication and admin middleware. [1] [2]User Model and API Enhancements:
IsAdminboolean field to theUsermodel inbackend/models/models.go, and exposed it in the user API responses. [1] [2] [3]Admin User Initialization:
seedAdminfunction inbackend/main.goto create or update an initial admin user ([email protected]) with a default password and admin privileges.Other Improvements:
backend/main.goto support new functionality (e.g.,uuid,utils,models). [1] [2]These changes collectively provide a secure and robust foundation for admin operations in the application.