Skip to content

Commit

Permalink
[utils] Fix webview login on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod committed Oct 26, 2022
1 parent cf22de2 commit f80ceb5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions legendary/utils/webview_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def on_loaded(self):
if 'logout' in url and self.callback_sid:
# prepare to close browser after logout redirect
self.destroy_on_load = True
elif 'logout' in url:
self.inject_js = True

def nop(self, *args, **kwargs):
return
Expand Down Expand Up @@ -124,10 +126,19 @@ def login_sid(self, sid_json):

def do_webview_login(callback_sid=None, callback_code=None):
api = MockLauncher(callback_sid=callback_sid, callback_code=callback_code)
url = login_url

if os.name == 'nt':
# On Windows we open the logout URL first to invalidate the current cookies (if any).
# Additionally, we have to disable JS injection for the first load, as otherwise the user
# will get an error for some reason.
url = logout_url
api.inject_js = False

logger.info('Opening Epic Games login window...')
# Open logout URL first to remove existing cookies, then redirect to login.
window = webview.create_window(f'Legendary {__version__} - Epic Games Account Login',
url=logout_url if not callback_sid else login_url,
width=768, height=1024, js_api=api)
url=url, width=768, height=1024, js_api=api)
api.window = window
window.events.loaded += api.on_loaded

Expand Down

0 comments on commit f80ceb5

Please sign in to comment.