feat: add operational panel presentation helpers

This commit is contained in:
gti
2026-09-22 16:59:05 -03:00
parent 9f1c259c3e
commit 0846b9d1b0
6 changed files with 174 additions and 1 deletions
+4
View File
@@ -39,6 +39,10 @@ def create_admin(session, username: str, password: str):
username = username.strip().lower()
if len(username) < 3:
raise ValueError("username must have 3 characters")
environment = os.getenv("APP_ENV") or settings.environment
weak_passwords_allowed = os.getenv("ALLOW_WEAK_DEV_PASSWORD", "1" if settings.allow_weak_dev_password else "0") == "1"
if len(password) < 12 and (environment.strip().lower() == "production" or not weak_passwords_allowed):
raise ValueError("password must have 12 characters")
if session.scalar(select(AdminUser).where(AdminUser.username == username)):
raise ValueError("username already exists")
admin = AdminUser(username=username, password_hash=hash_password(password))