feat: harden single-user account authentication
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Successful in 5m47s

This commit is contained in:
渡口浪人
2026-10-20 16:06:24 +08:00
parent ecfa17607f
commit 09c6773d76
4 changed files with 210 additions and 63 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ if len(password) < 8 or password != getpass.getpass("Confirm password: "):
args.config_dir.mkdir(parents=True, exist_ok=True)
path = args.config_dir / "accounts.json"
users = json.loads(path.read_text()).get("users", []) if path.exists() else []
if any(u["username"] == args.username for u in users):
sys.exit("Bootstrap user already exists. Change the password in Settings.")
if users:
sys.exit("Single-user account already exists. Change the password in Settings.")
users.append({"username": args.username, "password_hash": password_hash(password)})
path.write_text(json.dumps({"users": users}) + "\n")
path.chmod(0o600)