Enhance admin bootstrap process with reset functionality
- Update .env.example and README.md to include new ADMIN_BOOTSTRAP_RESET option for resetting admin credentials on startup. - Modify main.py to implement logic for resetting the admin's password, role, and status if ADMIN_BOOTSTRAP_RESET is set to true. - Adjust config.py to define the new setting, ensuring proper configuration management.
This commit is contained in:
@@ -97,6 +97,12 @@ def _bootstrap_admin() -> None:
|
||||
try:
|
||||
existing = db.query(User).filter(User.email == settings.admin_bootstrap_email).first()
|
||||
if existing:
|
||||
if settings.admin_bootstrap_reset:
|
||||
existing.password_hash = hash_password(settings.admin_bootstrap_password)
|
||||
existing.is_admin = True
|
||||
existing.role = "admin"
|
||||
existing.is_active = True
|
||||
db.commit()
|
||||
return
|
||||
user = User(
|
||||
email=settings.admin_bootstrap_email,
|
||||
|
||||
Reference in New Issue
Block a user