pass the initial username and password to log_in explicitly

master
magical 2022-08-06 05:20:39 +00:00
parent b1d1de659d
commit 3e4f3de2a8
1 changed files with 8 additions and 8 deletions

View File

@ -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):