1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

Force re-authentication on 4xx return from cAPI

Fixes #398
This commit is contained in:
Jonathan Harris 2019-01-17 16:01:54 +00:00
parent d4cb8b8ff6
commit 21b70cccfd

View File

@ -343,15 +343,16 @@ class Session:
if __debug__: print_exc()
raise ServerError()
if r.url.startswith(SERVER_AUTH):
# Redirected back to Auth server - force full re-authentication
if 400 <= r.status_code < 500 or r.url.startswith(SERVER_AUTH):
# Client error or redirected back to Auth server - force full re-authentication
self.dump(r)
self.invalidate()
self.login()
raise CredentialsError()
elif 500 <= r.status_code < 600:
# Server error. Typically 500 "Internal Server Error" if server is down
self.dump(r)
raise ServerError() # Typically 500 "Internal Server Error" if server is down
raise ServerError()
try:
data = r.json() # Will fail here if token expired since response is empty