From 3e4f3de2a8ed33aa316eb5b875ec0fa06b54a9b1 Mon Sep 17 00:00:00 2001 From: magical Date: Sat, 6 Aug 2022 05:20:39 +0000 Subject: [PATCH] pass the initial username and password to log_in explicitly --- clients/urwid/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/clients/urwid/main.py b/clients/urwid/main.py index dadb23e..14778fa 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -2395,18 +2395,17 @@ def nameloop(prompt, positive): return name -def log_in(relog=False): +def log_in(relog=False, name="", password=""): """ Handles login or registration using an oldschool input() chain. The user is run through this before starting the - curses app. + curses app. A default name and password can be passed in + if relog is False. """ if relog: name = sane_value("user_name", "Username", return_empty=True) else: - name = get_arg("user") \ - or os.getenv("BBJ_USER") \ - or sane_value("user_name", "Username", return_empty=True) + name = name or sane_value("user_name", "Username", return_empty=True) if name == "": motherfucking_rainbows("~~W3 4R3 4n0nYm0u5~~") else: @@ -2415,8 +2414,7 @@ def log_in(relog=False): try: network.set_credentials( name, - os.getenv("BBJ_PASSWORD", default="") - if not relog else "" + password if not relog else "" ) # make it easy for people who use an empty password =) motherfucking_rainbows("~~welcome back {}~~".format(network.user_name)) @@ -2584,7 +2582,9 @@ def main(): motherfucking_rainbows(obnoxious_logo) print(welcome) try: - log_in() + user_name = get_arg("user") or os.getenv("BBJ_USER") + password = os.getenv("BBJ_PASSWORD", default="") + log_in(name=user_name, password=password) app.index() app.loop.run() except (InterruptedError, KeyboardInterrupt):