Force re-authentication on 4xx return from cAPI

Fixes #398
This commit is contained in:
Jonathan Harris committed 2019-01-17 16:08:00 +00:00
1 parent d4cb8b8ff6
commit 21b70cccfd
1 file changed
+4 -3
+4 -3
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