mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Make login parametrized with a force_logout boolean
Instead of using a separate function to force logging out before login, login now has a boolean parameter that instructs it to logout before loging in again, if the user is alread logged in. It then starts the authorization with a force browser logout first. CURA-7427
This commit is contained in:
parent
898ca852f0
commit
eac4d3e463
3 changed files with 20 additions and 32 deletions
|
|
@ -90,23 +90,23 @@ class Account(QObject):
|
|||
self.loginStateChanged.emit(logged_in)
|
||||
|
||||
@pyqtSlot()
|
||||
def login(self) -> None:
|
||||
if self._logged_in:
|
||||
# Nothing to do, user already logged in.
|
||||
return
|
||||
self._authorization_service.startAuthorizationFlow()
|
||||
|
||||
@pyqtSlot()
|
||||
def loginWithForcedLogout(self) -> None:
|
||||
@pyqtSlot(bool)
|
||||
def login(self, force_logout_before_login: bool = False) -> None:
|
||||
"""
|
||||
Forces a logout from Cura and then initiates the authorization flow with the force_browser_logout variable
|
||||
as true, to sync the accounts in Cura and in the browser.
|
||||
Initializes the login process. If the user is logged in already and force_logout_before_login is true, Cura will
|
||||
logout from the account before initiating the authorization flow. If the user is logged in and
|
||||
force_logout_before_login is false, the function will return, as there is nothing to do.
|
||||
|
||||
:param force_logout_before_login: Optional boolean parameter
|
||||
:return: None
|
||||
"""
|
||||
if self._logged_in:
|
||||
self.logout()
|
||||
self._authorization_service.startAuthorizationFlow(True)
|
||||
if force_logout_before_login:
|
||||
self.logout()
|
||||
else:
|
||||
# Nothing to do, user already logged in.
|
||||
return
|
||||
self._authorization_service.startAuthorizationFlow(force_logout_before_login)
|
||||
|
||||
@pyqtProperty(str, notify=loginStateChanged)
|
||||
def userName(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue