feat: Implement admin role validation and enhance user management scripts
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 17s

This commit is contained in:
2026-02-08 23:19:30 -05:00
parent 060b2953fa
commit 27f02224ab
8 changed files with 227 additions and 34 deletions

58
backend/scripts/README.md Normal file
View File

@@ -0,0 +1,58 @@
# Backend Scripts
Utility scripts for backend management tasks.
## create_admin.py
Creates an admin user account with elevated privileges.
### Usage
```bash
cd backend
python scripts/create_admin.py
```
The script will prompt you for:
- Email address
- Password (minimum 8 characters)
- First name
- Last name
### Security Notes
- Admin users can only be created through this script or direct database manipulation
- The admin role cannot be assigned through the signup API
- Existing email addresses will be rejected
- Passwords are hashed using werkzeug's secure hash algorithm
### Example
```bash
$ python scripts/create_admin.py
=== Create Admin User ===
Email: admin@example.com
Password: ********
First name: Admin
Last name: User
Create admin user 'admin@example.com'? (yes/no): yes
✓ Admin user created successfully!
Email: admin@example.com
Name: Admin User
Role: admin
```
## Requirements
The script requires the backend virtual environment to be activated:
```bash
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate
```