Spaces:
Sleeping
Sleeping
File size: 1,622 Bytes
1fce3ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | """
Create admin user for Legal Tech Platform
Run this script to create the first admin user
"""
from app.core.database import SessionLocal
from app.models.user import User, UserRole
from app.core.security import get_password_hash
from datetime import datetime
def create_admin():
db = SessionLocal()
try:
# Check if admin already exists
existing_admin = db.query(User).filter(User.email == "admin@legaltech.com").first()
if existing_admin:
print("❌ Admin user already exists!")
print(f" Email: {existing_admin.email}")
return
# Create admin user
admin = User(
email="admin@legaltech.com",
full_name="System Administrator",
full_name_ar="مدير النظام",
hashed_password=get_password_hash("admin123"),
role=UserRole.ADMIN,
is_active=True,
is_superuser=True,
created_at=datetime.utcnow()
)
db.add(admin)
db.commit()
db.refresh(admin)
print("✅ Admin user created successfully!")
print(f"\n📧 Email: admin@legaltech.com")
print(f"🔑 Password: admin123")
print(f"\n⚠️ IMPORTANT: Change this password after first login!")
except Exception as e:
print(f"❌ Error creating admin user: {e}")
db.rollback()
finally:
db.close()
if __name__ == "__main__":
print("🚀 Creating admin user for Legal Tech Platform...")
print("=" * 50)
create_admin()
print("=" * 50)
|