mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 16:39:00 +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,6 +74,7 @@ class AuthorizationService:
|
|||||||
"""
|
"""
|
||||||
if self._user_profile:
|
if self._user_profile:
|
||||||
# We already obtained the profile. No need to make another request for it.
|
# We already obtained the profile. No need to make another request for it.
|
||||||
|
if callback is not None:
|
||||||
callback(self._user_profile)
|
callback(self._user_profile)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -81,11 +82,13 @@ class AuthorizationService:
|
|||||||
def store_profile(profile: Optional["UserProfile"]):
|
def store_profile(profile: Optional["UserProfile"]):
|
||||||
if profile is not None:
|
if profile is not None:
|
||||||
self._user_profile = profile
|
self._user_profile = profile
|
||||||
|
if callback is not None:
|
||||||
callback(profile)
|
callback(profile)
|
||||||
elif self._auth_data:
|
elif self._auth_data:
|
||||||
# If there is no user profile from the JWT, we have to log in again.
|
# 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!")
|
Logger.warning("The user profile could not be loaded. The user must log in again!")
|
||||||
self.deleteAuthData()
|
self.deleteAuthData()
|
||||||
|
if callback is not None:
|
||||||
callback(None)
|
callback(None)
|
||||||
|
|
||||||
self._parseJWT(callback = store_profile)
|
self._parseJWT(callback = store_profile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user