Spaces:
Running

axeronis commited on
Commit
6e4dc3f
·
1 Parent(s): e2e2f52

Update logo to v3 based on user reference

Browse files
backend/scripts/reset_admin_password.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import sys
3
+ import os
4
+
5
+ # Add parent dir to path
6
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
7
+
8
+ from sqlmodel import select
9
+ from app.core.database import async_session_maker
10
+ from app.models.user import User
11
+ # Try importing from security module, fall back to model if needed, but create_superuser used this:
12
+ from app.core.security import get_password_hash
13
+
14
+ async def reset_password():
15
+ email = "axeroni.s2@gmail.com"
16
+ new_password = "vector7678"
17
+
18
+ print(f"Resetting password for: {email}")
19
+
20
+ async with async_session_maker() as session:
21
+ # Check if user exists
22
+ statement = select(User).where(User.email == email)
23
+ result = await session.execute(statement)
24
+ user = result.scalars().first() # Use scalars().first() for sqlmodel/sqlalchemy consistency
25
+
26
+ if not user:
27
+ print(f"User {email} not found!")
28
+ return
29
+
30
+ # Update password
31
+ user.hashed_password = get_password_hash(new_password)
32
+ session.add(user)
33
+ await session.commit()
34
+
35
+ print(f"Password updated successfully for {email}")
36
+ print(f"New password: {new_password}")
37
+
38
+ if __name__ == "__main__":
39
+ if sys.platform == 'win32':
40
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
41
+ asyncio.run(reset_password())