Files
AutonetSellCar/backend/reset_password.py
AutonetSellCar Deploy 1f0dcb1ddb Initial commit: AutonetSellCar platform with deployment system
- Frontend: Next.js 14 with TypeScript
- Backend: FastAPI with SQLAlchemy
- Agent: Carmodoo sync agent
- Deployment: Docker Compose based staging/production setup
- Scripts: Automated deployment with rollback support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 13:24:39 +09:00

56 lines
1.4 KiB
Python

"""
Password Reset Script
Usage: python reset_password.py <email> <new_password>
"""
import sqlite3
import os
import sys
import bcrypt
db_path = os.path.join(os.path.dirname(__file__), 'autonet.db')
def get_password_hash(password: str) -> str:
return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
def reset_password(email: str, new_password: str):
"""Reset user password"""
if not os.path.exists(db_path):
print(f"Database not found: {db_path}")
return False
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
# Check if user exists
cursor.execute("SELECT id, email FROM users WHERE email = ?", (email,))
user = cursor.fetchone()
if not user:
print(f"User not found: {email}")
conn.close()
return False
# Update password
password_hash = get_password_hash(new_password)
cursor.execute("UPDATE users SET password_hash = ? WHERE email = ?", (password_hash, email))
conn.commit()
print(f"Password reset successful for: {email}")
print(f" New password: {new_password}")
conn.close()
return True
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: python reset_password.py <email> <new_password>")
print("Example: python reset_password.py test@test.com password123")
sys.exit(1)
email = sys.argv[1]
password = sys.argv[2]
reset_password(email, password)