From acbbf83510a8daee4e0e42317cd1901f1f8d4220 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 19 Nov 2021 16:23:48 +0100 Subject: [PATCH] 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. --- cura/OAuth2/AuthorizationService.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cura/OAuth2/AuthorizationService.py b/cura/OAuth2/AuthorizationService.py index 3cb85c009e..c49055a82c 100644 --- a/cura/OAuth2/AuthorizationService.py +++ b/cura/OAuth2/AuthorizationService.py @@ -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)