import asyncio import sys import os # Add parent directory to path so we can import 'app' sys.path.append(os.path.dirname(os.path.abspath(__file__))) from sqlalchemy import select from app.core.database import AsyncSessionLocal from app.models.tenant import Tenant from app.models.ticket import Ticket from app.models.category import Category # ✅ AÑADIR ESTO from app.models.system import System # ✅ AÑADIR ESTO from app.models.user import User from app.core.security import SecurityUtils async def fix_password(): async with AsyncSessionLocal() as session: # Find the admin user email = "admin@aduanasoft.com" result = await session.execute(select(User).where(User.email == email)) user = result.scalar_one_or_none() if user: print(f"User {email} found.") # Reset password to 'admin123' new_password = "admin123" hashed = SecurityUtils.hash_password(new_password) user.password_hash = hashed try: await session.commit() print(f"Password for {email} updated successfully!") print(f"New password is: {new_password}") except Exception as e: await session.rollback() print(f"Error updating password: {e}") else: print(f"User {email} not found!") if __name__ == "__main__": asyncio.run(fix_password())