mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 07:28:59 +08: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
@ -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…
x
Reference in New Issue
Block a user