Initial commit - Customer Portal for Coolify

This commit is contained in:
2025-12-17 10:08:34 +01:00
commit 9fca32567c
153 changed files with 16432 additions and 0 deletions

View File

@@ -0,0 +1 @@
"""Portal management scripts."""

Binary file not shown.

View File

@@ -0,0 +1,65 @@
"""Create initial admin user.
Run with:
docker exec customer_portal python -m customer_portal.scripts.create_admin
"""
import os
from sqlalchemy import create_engine, text
from werkzeug.security import generate_password_hash
def create_admin():
"""Create initial admin user if none exists."""
database_url = os.environ.get(
"DATABASE_URL", "postgresql://portal:portal@localhost:5432/customer_portal"
)
engine = create_engine(database_url)
with engine.connect() as conn:
# Check if any admin exists
result = conn.execute(text("SELECT COUNT(*) FROM admin_users"))
count = result.fetchone()[0]
if count > 0:
print(f"Es existieren bereits {count} Admin(s).")
result = conn.execute(text("SELECT username, name FROM admin_users"))
for row in result:
print(f" - {row[0]} ({row[1]})")
return
# Create default admin
username = "admin"
password = "admin123!"
password_hash = generate_password_hash(password)
conn.execute(
text(
"""
INSERT INTO admin_users (username, password_hash, name, email, is_active)
VALUES (:username, :password_hash, :name, :email, TRUE)
"""
),
{
"username": username,
"password_hash": password_hash,
"name": "Administrator",
"email": "admin@example.com",
},
)
conn.commit()
print("=" * 50)
print("Admin-Benutzer erfolgreich erstellt!")
print("=" * 50)
print(f" Benutzername: {username}")
print(f" Passwort: {password}")
print("")
print("WICHTIG: Aendern Sie das Passwort nach dem ersten Login!")
print("=" * 50)
if __name__ == "__main__":
create_admin()