46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""
|
|
Reset admin user password to 'cosmo'
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
sys.path.insert(0, '/Users/jiliu/WorkSpace/cosmo/backend')
|
|
|
|
from sqlalchemy import select, update
|
|
from app.database import AsyncSessionLocal
|
|
from app.models.db import User
|
|
|
|
|
|
async def reset_password():
|
|
# Pre-generated bcrypt hash for 'cosmo'
|
|
new_hash = '$2b$12$42d8/NAaYJlK8w/1yBd5uegdHlDkpC9XFtXYu2sWq0EXj48KAMZ0i'
|
|
|
|
async with AsyncSessionLocal() as session:
|
|
# Find admin user
|
|
result = await session.execute(
|
|
select(User).where(User.username == 'cosmo')
|
|
)
|
|
user = result.scalar_one_or_none()
|
|
|
|
if not user:
|
|
print("❌ Admin user 'cosmo' not found!")
|
|
return
|
|
|
|
print(f"Found user: {user.username}")
|
|
print(f"New password hash: {new_hash[:50]}...")
|
|
|
|
# Update password
|
|
await session.execute(
|
|
update(User)
|
|
.where(User.username == 'cosmo')
|
|
.values(password_hash=new_hash)
|
|
)
|
|
await session.commit()
|
|
|
|
print("✅ Admin password reset successfully!")
|
|
print("Username: cosmo")
|
|
print("Password: cosmo")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(reset_password())
|