import sqlite3
import sys
sys.path.insert(0, ".")
db = sqlite3.connect("db/memos.db")
db.row_factory = sqlite3.Row
cur = db.cursor()
cur.execute("SELECT id, username, password_hash FROM cuccu_users WHERE username = 'e2etest'")
row = cur.fetchone()
if row:
    print("Hash:", row["password_hash"][:30], "...")
    # Test verify
    try:
        from common.jwt_auth import verify_password, get_password_hash
        result = verify_password("Test12345!", row["password_hash"])
        print("Password verify:", result)
        if not result:
            # Re-hash with proper function
            new_hash = get_password_hash("Test12345!")
            cur.execute("UPDATE cuccu_users SET password_hash = ? WHERE username = 'e2etest'", (new_hash,))
            db.commit()
            print("Updated hash to:", new_hash[:30], "...")
            # Verify again
            print("Re-verify:", verify_password("Test12345!", new_hash))
    except Exception as e:
        print("Error:", e)
db.close()
