Files
KittyRec2018-Leak/tracking/password_tracking.py
2026-07-24 15:25:04 +00:00

39 lines
716 B
Python

import json
import os
import threading
_LOCK = threading.Lock()
_PATH = os.path.join(os.path.dirname(__file__), "password_resets.json")
def _read():
try:
with open(_PATH, "r") as f:
return set(json.load(f))
except (FileNotFoundError, json.JSONDecodeError):
return set()
def _write(ids):
with open(_PATH, "w") as f:
json.dump(sorted(ids), f)
def mark_password_set(pid: int):
with _LOCK:
ids = _read()
ids.add(pid)
_write(ids)
def clear_password_set(pid: int):
with _LOCK:
ids = _read()
ids.discard(pid)
_write(ids)
def has_real_password(pid: int) -> bool:
with _LOCK:
return pid in _read()