mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 19:57:51 -06:00
Fix description comment of _generate_auth_url()
CURA-7427
This commit is contained in:
parent
f6ebac6e34
commit
32efb8d7bb
2 changed files with 11 additions and 8 deletions
|
@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
||||||
from cura.OAuth2.Models import UserProfile, OAuth2Settings
|
from cura.OAuth2.Models import UserProfile, OAuth2Settings
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
|
|
||||||
MYCLOUD_LOGOFF = "https://mycloud.ultimaker.com/logoff"
|
MYCLOUD_LOGOFF_URL = "https://mycloud.ultimaker.com/logoff"
|
||||||
|
|
||||||
## The authorization service is responsible for handling the login flow,
|
## The authorization service is responsible for handling the login flow,
|
||||||
# storing user credentials and providing account information.
|
# storing user credentials and providing account information.
|
||||||
|
@ -184,14 +184,17 @@ class AuthorizationService:
|
||||||
If there is a request to force logging out of mycloud in the browser, the link to logoff from mycloud is
|
If there is a request to force logging out of mycloud in the browser, the link to logoff from mycloud is
|
||||||
prepended in order to force the browser to logoff from mycloud and then redirect to the authentication url to
|
prepended in order to force the browser to logoff from mycloud and then redirect to the authentication url to
|
||||||
login again. This case is used to sync the accounts between Cura and the browser.
|
login again. This case is used to sync the accounts between Cura and the browser.
|
||||||
:param query_parameters_dict:
|
|
||||||
:param force_browser_logout:
|
:param query_parameters_dict: A dictionary with the query parameters to be url encoded and added to the
|
||||||
:return:
|
authentication link
|
||||||
|
:param force_browser_logout: If True, Cura will prepend the MYCLOUD_LOGOFF_URL link before the authentication
|
||||||
|
link to force the a browser logout from mycloud.ultimaker.com
|
||||||
|
:return: The authentication URL, properly formatted and encoded
|
||||||
"""
|
"""
|
||||||
auth_url = "{}?{}".format(self._auth_url, urlencode(query_parameters_dict))
|
auth_url = "{}?{}".format(self._auth_url, urlencode(query_parameters_dict))
|
||||||
if force_browser_logout:
|
if force_browser_logout:
|
||||||
# The url after '?next=' should be urlencoded
|
# The url after '?next=' should be urlencoded
|
||||||
auth_url = "{}?next={}".format(MYCLOUD_LOGOFF, quote_plus(auth_url))
|
auth_url = "{}?next={}".format(MYCLOUD_LOGOFF_URL, quote_plus(auth_url))
|
||||||
return auth_url
|
return auth_url
|
||||||
|
|
||||||
## Callback method for the authentication flow.
|
## Callback method for the authentication flow.
|
||||||
|
|
|
@ -7,7 +7,7 @@ from PyQt5.QtGui import QDesktopServices
|
||||||
|
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from cura.OAuth2.AuthorizationHelpers import AuthorizationHelpers, TOKEN_TIMESTAMP_FORMAT
|
from cura.OAuth2.AuthorizationHelpers import AuthorizationHelpers, TOKEN_TIMESTAMP_FORMAT
|
||||||
from cura.OAuth2.AuthorizationService import AuthorizationService, MYCLOUD_LOGOFF
|
from cura.OAuth2.AuthorizationService import AuthorizationService, MYCLOUD_LOGOFF_URL
|
||||||
from cura.OAuth2.LocalAuthorizationServer import LocalAuthorizationServer
|
from cura.OAuth2.LocalAuthorizationServer import LocalAuthorizationServer
|
||||||
from cura.OAuth2.Models import OAuth2Settings, AuthenticationResponse, UserProfile
|
from cura.OAuth2.Models import OAuth2Settings, AuthenticationResponse, UserProfile
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ def test__generate_auth_url() -> None:
|
||||||
"response_type": "code"
|
"response_type": "code"
|
||||||
}
|
}
|
||||||
auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = False)
|
auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = False)
|
||||||
assert MYCLOUD_LOGOFF + "?next=" not in auth_url
|
assert MYCLOUD_LOGOFF_URL + "?next=" not in auth_url
|
||||||
|
|
||||||
auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = True)
|
auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = True)
|
||||||
assert MYCLOUD_LOGOFF + "?next=" in auth_url
|
assert MYCLOUD_LOGOFF_URL + "?next=" in auth_url
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue