Initial commit - PromptTech

This commit is contained in:
2026-01-27 18:07:00 -06:00
commit 3959a223bf
262 changed files with 128736 additions and 0 deletions

50
backend/create_admin.py Normal file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""Script to create an admin user for the TechZone application"""
import asyncio
import sys
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
import bcrypt
from datetime import datetime, timezone
# Import from your app
sys.path.append('/media/pts/Website/PromptTech_Solution_Site/backend')
from models import User, UserRole
from database import DATABASE_URL
async def create_admin():
# Create async engine
engine = create_async_engine(DATABASE_URL, echo=True)
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async with async_session() as session:
# Admin credentials
email = "admin@prompttech.com"
password = "admin123"
name = "Admin User"
# Hash password
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
# Create admin user
admin_user = User(
email=email,
name=name,
password=hashed_password,
role=UserRole.ADMIN,
created_at=datetime.now(timezone.utc)
)
session.add(admin_user)
await session.commit()
await session.refresh(admin_user)
print(f"\n✅ Admin user created successfully!")
print(f"Email: {email}")
print(f"Password: {password}")
print(f"Role: {admin_user.role.value}")
print(f"\n🔐 Please change the password after first login!\n")
if __name__ == "__main__":
asyncio.run(create_admin())