Files
service-finder/backend/reset_test_user_password.py

62 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""
Reset password for tester_pro@profibot.hu to 'Password123!'
"""
import sys
import os
sys.path.insert(0, '/app/backend')
from app.core.security import get_password_hash
from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker
# Database URL from environment
DATABASE_URL = "postgresql+psycopg2://kincses:MiskociA74@shared-postgres:5432/service_finder"
def reset_password():
"""Reset password for tester_pro@profibot.hu"""
engine = create_engine(DATABASE_URL)
Session = sessionmaker(bind=engine)
session = Session()
try:
# Get password hash for 'Password123!'
password_hash = get_password_hash("Password123!")
print(f"Password hash for 'Password123!': {password_hash}")
# Update the user
update_stmt = text("""
UPDATE identity.users
SET hashed_password = :password_hash
WHERE email = :email
""")
result = session.execute(
update_stmt,
{"password_hash": password_hash, "email": "tester_pro@profibot.hu"}
)
session.commit()
if result.rowcount > 0:
print(f"Successfully updated password for tester_pro@profibot.hu")
return True
else:
print(f"User not found: tester_pro@profibot.hu")
return False
except Exception as e:
print(f"Error: {e}")
session.rollback()
return False
finally:
session.close()
if __name__ == "__main__":
print("Resetting password for tester_pro@profibot.hu...")
if reset_password():
print("Password reset successful")
sys.exit(0)
else:
print("Password reset failed")
sys.exit(1)