mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[cli/utils] Fix webview login on Windows
Now using exchange code every time!
This commit is contained in:
parent
f26c8ab0a1
commit
5a20f12461
|
@ -165,7 +165,7 @@ class LegendaryCLI:
|
||||||
sid = sid.strip('"')
|
sid = sid.strip('"')
|
||||||
exchange_token = self.core.auth_sid(sid)
|
exchange_token = self.core.auth_sid(sid)
|
||||||
else:
|
else:
|
||||||
if do_webview_login(callback_sid=self.core.auth_sid, callback_code=self.core.auth_code):
|
if do_webview_login(callback_code=self.core.auth_code):
|
||||||
logger.info(f'Successfully logged in as "{self.core.lgd.userdata["displayName"]}" via WebView')
|
logger.info(f'Successfully logged in as "{self.core.lgd.userdata["displayName"]}" via WebView')
|
||||||
else:
|
else:
|
||||||
logger.error('WebView login attempt failed, please see log for details.')
|
logger.error('WebView login attempt failed, please see log for details.')
|
||||||
|
|
|
@ -70,7 +70,7 @@ class MockLauncher:
|
||||||
if self.inject_js:
|
if self.inject_js:
|
||||||
self.window.evaluate_js(window_js)
|
self.window.evaluate_js(window_js)
|
||||||
|
|
||||||
if 'logout' in url:
|
if 'logout' in url and self.callback_sid:
|
||||||
# prepare to close browser after logout redirect
|
# prepare to close browser after logout redirect
|
||||||
self.destroy_on_load = True
|
self.destroy_on_load = True
|
||||||
|
|
||||||
|
@ -87,16 +87,17 @@ class MockLauncher:
|
||||||
# skip logging out on those platforms and directly use the exchange code we're given.
|
# skip logging out on those platforms and directly use the exchange code we're given.
|
||||||
# On windows we have to do a little dance with the SID to create a session that
|
# On windows we have to do a little dance with the SID to create a session that
|
||||||
# remains valid after logging out in the embedded browser.
|
# remains valid after logging out in the embedded browser.
|
||||||
if self.window.gui.renderer in ('gtkwebkit2', 'qtwebengine', 'qtwebkit'):
|
# Update: Epic broke SID login, we'll also do this on Windows now
|
||||||
self.destroy_on_load = True
|
# if self.window.gui.renderer in ('gtkwebkit2', 'qtwebengine', 'qtwebkit'):
|
||||||
try:
|
self.destroy_on_load = True
|
||||||
self.callback_result = self.callback_code(exchange_code)
|
try:
|
||||||
except Exception as e:
|
self.callback_result = self.callback_code(exchange_code)
|
||||||
logger.error(f'Logging in via exchange-code failed with {e!r}')
|
except Exception as e:
|
||||||
finally:
|
logger.error(f'Logging in via exchange-code failed with {e!r}')
|
||||||
# We cannot destroy the browser from here,
|
finally:
|
||||||
# so we'll load a small goodbye site first.
|
# We cannot destroy the browser from here,
|
||||||
self.window.load_url(goodbye_url)
|
# so we'll load a small goodbye site first.
|
||||||
|
self.window.load_url(goodbye_url)
|
||||||
|
|
||||||
def trigger_sid_exchange(self, *args, **kwargs):
|
def trigger_sid_exchange(self, *args, **kwargs):
|
||||||
# check if code-based login hasn't already set the destroy flag
|
# check if code-based login hasn't already set the destroy flag
|
||||||
|
@ -125,7 +126,8 @@ def do_webview_login(callback_sid=None, callback_code=None):
|
||||||
api = MockLauncher(callback_sid=callback_sid, callback_code=callback_code)
|
api = MockLauncher(callback_sid=callback_sid, callback_code=callback_code)
|
||||||
logger.info('Opening Epic Games login window...')
|
logger.info('Opening Epic Games login window...')
|
||||||
window = webview.create_window(f'Legendary {__version__} - Epic Games Account Login',
|
window = webview.create_window(f'Legendary {__version__} - Epic Games Account Login',
|
||||||
url=login_url, width=768, height=1024, js_api=api)
|
url=logout_url if not callback_sid else login_url,
|
||||||
|
width=768, height=1024, js_api=api)
|
||||||
api.window = window
|
api.window = window
|
||||||
window.events.loaded += api.on_loaded
|
window.events.loaded += api.on_loaded
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue