Spaces:
Running

File size: 1,373 Bytes
6e4dc3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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())