import asyncio import sys import os # Add parent dir to path sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sqlmodel import select from app.core.database import async_session_maker from app.models.user import User # Try importing from security module, fall back to model if needed, but create_superuser used this: from app.core.security import get_password_hash async def reset_password(): email = "axeroni.s2@gmail.com" new_password = "vector7678" print(f"Resetting password for: {email}") async with async_session_maker() as session: # Check if user exists statement = select(User).where(User.email == email) result = await session.execute(statement) user = result.scalars().first() # Use scalars().first() for sqlmodel/sqlalchemy consistency if not user: print(f"User {email} not found!") return # Update password user.hashed_password = get_password_hash(new_password) session.add(user) await session.commit() print(f"Password updated successfully for {email}") print(f"New password: {new_password}") if __name__ == "__main__": if sys.platform == 'win32': asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(reset_password())