Spaces:
Paused
Paused
| #!/usr/bin/env python | |
| """Update admin user password with correct hashing.""" | |
| import sys | |
| from pathlib import Path | |
| # Add backend to path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker | |
| from app.modules.auth.service import security | |
| from core.models.user import User | |
| def update_admin_password(): | |
| """Update admin user password with correct hashing.""" | |
| database_url = f"sqlite:///{Path.home()}/.zenith/fraud_detection.db" | |
| engine = create_engine(database_url) | |
| session_local = sessionmaker(bind=engine) | |
| db = session_local() | |
| try: | |
| # Find admin user | |
| admin_user = db.query(User).filter(User.email == "admin@zenith.com").first() | |
| if not admin_user: | |
| print("β Admin user not found!") | |
| return | |
| # Update password with correct hashing | |
| admin_user.password_hash = security.get_password_hash("password123") | |
| db.commit() | |
| print("β Admin password updated successfully!") | |
| print(f" User ID: {admin_user.id}") | |
| print(f" Email: {admin_user.email}") | |
| print(f" Role: {admin_user.role}") | |
| except Exception as e: | |
| print(f"β Error updating password: {e}") | |
| db.rollback() | |
| finally: | |
| db.close() | |
| if __name__ == "__main__": | |
| update_admin_password() | |