Skip to content

Commit

Permalink
Revert "Change bool setting to more flexible callback function"
Browse files Browse the repository at this point in the history
This reverts commit ff47855.
  • Loading branch information
rburema committed Jan 18, 2024
1 parent a17d0a1 commit 5bcc37d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cura/OAuth2/AuthorizationService.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AuthorizationService:
def __init__(self,
settings: "OAuth2Settings",
preferences: Optional["Preferences"] = None,
callback_auth_data_retrieved: Callable[[], None] = None) -> None:
get_user_profile: bool = True) -> None:
# Emit signal when authentication is completed.
self.onAuthStateChanged = Signal()

Expand All @@ -48,7 +48,7 @@ def __init__(self,
self._auth_url = "{}/authorize".format(self._settings.OAUTH_SERVER_URL)
self._auth_data: Optional[AuthenticationResponse] = None
self._user_profile: Optional["UserProfile"] = None
self._callback_auth_data_retrieved = self.getUserProfile if callback_auth_data_retrieved is None else callback_auth_data_retrieved
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.
Expand Down Expand Up @@ -298,7 +298,8 @@ def _storeAuthData(self, auth_data: Optional[AuthenticationResponse] = None) ->
self._auth_data = auth_data
self._currently_refreshing_token = False
if auth_data:
self._callback_auth_data_retrieved()
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")
Expand Down

0 comments on commit 5bcc37d

Please sign in to comment.