Merge remote-tracking branch 'origin/main' into CURA-11406_fix_auth_refresh_after_sleep

This commit is contained in:
Remco Burema 2024-02-14 10:31:17 +01:00
commit fc0d1a54f3
577 changed files with 7380 additions and 910 deletions

View file

@ -32,20 +32,24 @@ class AuthorizationService:
account information.
"""
# Emit signal when authentication is completed.
onAuthStateChanged = Signal()
def __init__(self,
settings: "OAuth2Settings",
preferences: Optional["Preferences"] = None,
get_user_profile: bool = True) -> None:
# Emit signal when authentication is completed.
self.onAuthStateChanged = Signal()
# Emit signal when authentication failed.
onAuthenticationError = Signal()
# Emit signal when authentication failed.
self.onAuthenticationError = Signal()
accessTokenChanged = Signal()
self.accessTokenChanged = Signal()
def __init__(self, settings: "OAuth2Settings", preferences: Optional["Preferences"] = None) -> None:
self._settings = settings
self._auth_helpers = AuthorizationHelpers(settings)
self._auth_url = "{}/authorize".format(self._settings.OAUTH_SERVER_URL)
self._auth_data: Optional[AuthenticationResponse] = None
self._user_profile: Optional["UserProfile"] = None
self._get_user_profile: bool = get_user_profile
self._preferences = preferences
self._server = LocalAuthorizationServer(self._auth_helpers, self._onAuthStateChanged, daemon=True)
self._currently_refreshing_token = False # Whether we are currently in the process of refreshing auth. Don't make new requests while busy.
@ -314,7 +318,8 @@ class AuthorizationService:
self._auth_data = auth_data
self._currently_refreshing_token = False
if auth_data:
self.getUserProfile()
if self._get_user_profile:
self.getUserProfile()
self._preferences.setValue(self._settings.AUTH_DATA_PREFERENCE_KEY, json.dumps(auth_data.dump()))
else:
Logger.log("d", "Clearing the user profile")