homelab_automation/reset_password.py
Bruno Charest c3cd7c2621
Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
feat: Implement initial Homelab Automation API v2 with new models, routes, and core architecture, including a SQLAlchemy model refactoring script.
2026-03-03 20:18:22 -05:00

30 lines
1005 B
Python

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 <username> <nouveau_mot_de_passe>")
else:
asyncio.run(reset_password(sys.argv[1], sys.argv[2]))