mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Improved error handling of authentication
This commit is contained in:
parent
f9f83981bb
commit
6e84d39cae
1 changed files with 5 additions and 1 deletions
|
@ -427,7 +427,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._requestAuthentication()
|
self._requestAuthentication()
|
||||||
elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 403:
|
elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 403:
|
||||||
pass
|
pass
|
||||||
else:
|
elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
|
||||||
self.setAuthenticationState(AuthState.Authenticated)
|
self.setAuthenticationState(AuthState.Authenticated)
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
## Save authentication details.
|
## Save authentication details.
|
||||||
|
@ -441,6 +441,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
else:
|
else:
|
||||||
global_container_stack.addMetaDataEntry("network_authentication_id", self._authentication_id)
|
global_container_stack.addMetaDataEntry("network_authentication_id", self._authentication_id)
|
||||||
Logger.log("i", "Authentication succeeded")
|
Logger.log("i", "Authentication succeeded")
|
||||||
|
else: # Got a response that we didn't expect, so something went wrong.
|
||||||
|
Logger.log("w", "While trying to authenticate, we got an unexpected response: %s", reply.attribute(QNetworkRequest.HttpStatusCodeAttribute))
|
||||||
|
self.setAuthenticationState(AuthState.NotAuthenticated)
|
||||||
|
|
||||||
elif "auth/check" in reply.url().toString(): # Check if we are authenticated (user can refuse this!)
|
elif "auth/check" in reply.url().toString(): # Check if we are authenticated (user can refuse this!)
|
||||||
data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||||
if data.get("message", "") == "authorized":
|
if data.get("message", "") == "authorized":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue