Create a default account from PLAYER_USER/PLAYER_PASSWORD
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6865bbdb72
commit
c699aca5b0
3 files changed
+27
-2
No files matched your search
@@ -317,8 +317,18 @@ def serve(argv):
|
||||
ap.add_argument("--port", type=int, default=int(os.environ.get("PORT", 8080)))
|
||||
ap.add_argument("--host", default="0.0.0.0")
|
||||
a = ap.parse_args(argv)
|
||||
if not read(F_USERS, {}):
|
||||
sys.exit("No accounts yet. Run: python3 server.py adduser YOURNAME")
|
||||
users = read(F_USERS, {})
|
||||
du, dp = os.environ.get("PLAYER_USER", "").strip().lower(), os.environ.get("PLAYER_PASSWORD", "")
|
||||
if du and dp and du not in users: # default account for containers; never overwrites an existing one
|
||||
users[du] = hash_pw(dp)
|
||||
write(F_USERS, users, private=True)
|
||||
if len(users) == 1 and os.path.exists(F_LEGACY):
|
||||
legacy = read(F_LEGACY, {})
|
||||
if legacy and all(isinstance(v, dict) and "pos" in v for v in legacy.values()):
|
||||
write(F_PROGRESS, {du: legacy})
|
||||
print(f"Created default account '{du}'.")
|
||||
if not users:
|
||||
sys.exit("No accounts yet. Run: python3 server.py adduser NAME (or set PLAYER_USER and PLAYER_PASSWORD)")
|
||||
if not oa_login()[0]:
|
||||
print("Note: no OpenAudible login set. Run `python3 server.py setup` or set OPENAUDIBLE_USER/OPENAUDIBLE_PASSWORD.")
|
||||
Handler.upstream = a.upstream.rstrip("/")
|
||||
|
||||
Reference in new issue
Block a user