Multi-tenant Claude Code monitoring dashboard. FastAPI + PostgreSQL + Docker + SSE real-time updates. Montserrat font, black/#FFC407 color scheme. Apache reverse proxy config at /cc-dashboard/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Run inside Docker to create the first admin user.
|
|
docker compose exec app python scripts/create_admin.py
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
from src.auth import hash_password
|
|
from src.database import AsyncSessionLocal
|
|
from src.models import User
|
|
from sqlalchemy import select
|
|
|
|
|
|
async def main():
|
|
email = input("Admin email: ").strip()
|
|
username = input("Username: ").strip()
|
|
password = input("Password (min 8 chars): ").strip()
|
|
|
|
if len(password) < 8:
|
|
print("Password too short")
|
|
sys.exit(1)
|
|
|
|
async with AsyncSessionLocal() as db:
|
|
existing = await db.execute(select(User).where(User.email == email))
|
|
if existing.scalar_one_or_none():
|
|
print(f"User {email} already exists")
|
|
sys.exit(1)
|
|
|
|
user = User(
|
|
email=email,
|
|
username=username,
|
|
password_hash=hash_password(password),
|
|
role="admin",
|
|
)
|
|
db.add(user)
|
|
await db.commit()
|
|
print(f"Admin created: {email}")
|
|
|
|
|
|
asyncio.run(main())
|