mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-11 23:49:04 +08:00
Allow for OAuth service to stop after token has been retrieved
This commit is contained in:
parent
aac9af577b
commit
b794989468
@ -31,7 +31,10 @@ class AuthorizationService:
|
|||||||
account information.
|
account information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, settings: "OAuth2Settings", preferences: Optional["Preferences"] = None) -> None:
|
def __init__(self,
|
||||||
|
settings: "OAuth2Settings",
|
||||||
|
preferences: Optional["Preferences"] = None,
|
||||||
|
get_user_profile: bool = True) -> None:
|
||||||
# Emit signal when authentication is completed.
|
# Emit signal when authentication is completed.
|
||||||
self.onAuthStateChanged = Signal()
|
self.onAuthStateChanged = Signal()
|
||||||
|
|
||||||
@ -45,6 +48,7 @@ class AuthorizationService:
|
|||||||
self._auth_url = "{}/authorize".format(self._settings.OAUTH_SERVER_URL)
|
self._auth_url = "{}/authorize".format(self._settings.OAUTH_SERVER_URL)
|
||||||
self._auth_data: Optional[AuthenticationResponse] = None
|
self._auth_data: Optional[AuthenticationResponse] = None
|
||||||
self._user_profile: Optional["UserProfile"] = None
|
self._user_profile: Optional["UserProfile"] = None
|
||||||
|
self._get_user_profile: bool = get_user_profile
|
||||||
self._preferences = preferences
|
self._preferences = preferences
|
||||||
self._server = LocalAuthorizationServer(self._auth_helpers, self._onAuthStateChanged, daemon=True)
|
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.
|
self._currently_refreshing_token = False # Whether we are currently in the process of refreshing auth. Don't make new requests while busy.
|
||||||
@ -294,7 +298,8 @@ class AuthorizationService:
|
|||||||
self._auth_data = auth_data
|
self._auth_data = auth_data
|
||||||
self._currently_refreshing_token = False
|
self._currently_refreshing_token = False
|
||||||
if auth_data:
|
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()))
|
self._preferences.setValue(self._settings.AUTH_DATA_PREFERENCE_KEY, json.dumps(auth_data.dump()))
|
||||||
else:
|
else:
|
||||||
Logger.log("d", "Clearing the user profile")
|
Logger.log("d", "Clearing the user profile")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user