mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Deal with absence of callback function
It may be None, so then we don't need to call back. The consumer may just take it from self._user_profile. Contributes to issue CURA-8539.
This commit is contained in:
parent
a5202b61d2
commit
acbbf83510
1 changed files with 6 additions and 3 deletions
|
@ -74,19 +74,22 @@ class AuthorizationService:
|
|||
"""
|
||||
if self._user_profile:
|
||||
# We already obtained the profile. No need to make another request for it.
|
||||
callback(self._user_profile)
|
||||
if callback is not None:
|
||||
callback(self._user_profile)
|
||||
return
|
||||
|
||||
# If no user profile was stored locally, we try to get it from JWT.
|
||||
def store_profile(profile: Optional["UserProfile"]):
|
||||
if profile is not None:
|
||||
self._user_profile = profile
|
||||
callback(profile)
|
||||
if callback is not None:
|
||||
callback(profile)
|
||||
elif self._auth_data:
|
||||
# If there is no user profile from the JWT, we have to log in again.
|
||||
Logger.warning("The user profile could not be loaded. The user must log in again!")
|
||||
self.deleteAuthData()
|
||||
callback(None)
|
||||
if callback is not None:
|
||||
callback(None)
|
||||
|
||||
self._parseJWT(callback = store_profile)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue