#!/usr/bin/env python3 """ Script to reset admin password. """ import asyncio import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) from sqlalchemy import select from passlib.context import CryptContext from app.database import AsyncSessionLocal from app.models.user import User ADMIN_EMAIL = "guggeryves@hotmail.com" NEW_PASSWORD = "Pounce2024!" # Strong password pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") async def reset_password(): """Reset admin password.""" print(f"šŸ” Resetting password for: {ADMIN_EMAIL}") async with AsyncSessionLocal() as db: result = await db.execute( select(User).where(User.email == ADMIN_EMAIL) ) user = result.scalar_one_or_none() if not user: print(f"āŒ User not found: {ADMIN_EMAIL}") return False # Hash new password hashed = pwd_context.hash(NEW_PASSWORD) user.hashed_password = hashed user.is_verified = True user.is_active = True user.is_admin = True await db.commit() print(f"āœ… Password reset successful!") print(f"\nšŸ“‹ LOGIN CREDENTIALS:") print(f" Email: {ADMIN_EMAIL}") print(f" Password: {NEW_PASSWORD}") print(f"\nāš ļø Please change this password after logging in!") return True if __name__ == "__main__": asyncio.run(reset_password())