feat: harden single-user account authentication
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user