Skip to content

Commit

Permalink
fix(auth): remove automatic browser open for 4xx status
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Aug 9, 2024
1 parent 819316e commit 937a867
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions arena/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,12 @@ def urlopen(self, url, data=None, creds=False, csrf=None):
return res.read().decode("utf-8")
except (requests.exceptions.ConnectionError, ConnectionError, URLError, HTTPError) as err:
print(f"{err}: {url}")
if isinstance(err, HTTPError) and round(err.code, -2) == 400:
if isinstance(err, HTTPError) and err.code in (401, 403):
# user not authorized on website yet, they don"t have an ARENA username
us = urlsplit(url)
base_url = f"{us.scheme}://{us.netloc}"
print("Login with this account on the website first:")
print(f"Trying to open login page: {base_url}/user")
try:
webbrowser.open_new_tab(f"{base_url}/user")
except (webbrowser.Error) as error:
print(f"Console-only login. {error}")
print(f"Do you have a valid ARENA account on {base_url}?")
print(f"You can create an account in a web browser at: {base_url}/user")
sys.exit("Terminating...")


Expand Down

0 comments on commit 937a867

Please # to comment.