import asyncio import sys import os # Ajouter le répertoire courant au PYTHONPATH pour trouver le module 'app' sys.path.insert(0, os.path.abspath(os.getcwd())) from app.models.database import async_session_maker from app.crud.user import UserRepository from app.services.auth_service import hash_password async def reset_password(username, new_password): async with async_session_maker() as session: repo = UserRepository(session) user = await repo.get_by_username(username) if not user: print(f"❌ Utilisateur '{username}' non trouvé.") return user.hashed_password = hash_password(new_password) await session.commit() print(f"✅ Mot de passe réinitialisé avec succès pour : {username}") if __name__ == "__main__": if len(sys.argv) < 3: print("Usage: python reset_password.py ") else: asyncio.run(reset_password(sys.argv[1], sys.argv[2]))