fix: Add some more error checking for hns login

This commit is contained in:
Nathan Woodburn 2025-02-20 21:43:17 +11:00
parent c0587769e3
commit 5071250dab
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -515,7 +515,12 @@ def auth_get():
# Check if user is valid
r = requests.get(f'https://login.hns.au/auth/user?token={token}')
if r.status_code != 200:
return redirect('/?error=Failed to login&reason=Failed to connect to HNS Login')
try:
r = r.json()
except:
return redirect('/?error=Failed to login&reason=Failed to connect to HNS Login')
if 'error' in r:
return redirect('/?error=Failed to login&reason=' + r['error'])