@@ -73,6 +73,8 @@ def on_loaded(self):
7373 if 'logout' in url and self .callback_sid :
7474 # prepare to close browser after logout redirect
7575 self .destroy_on_load = True
76+ elif 'logout' in url :
77+ self .inject_js = True
7678
7779 def nop (self , * args , ** kwargs ):
7880 return
@@ -124,10 +126,19 @@ def login_sid(self, sid_json):
124126
125127def do_webview_login (callback_sid = None , callback_code = None ):
126128 api = MockLauncher (callback_sid = callback_sid , callback_code = callback_code )
129+ url = login_url
130+
131+ if os .name == 'nt' :
132+ # On Windows we open the logout URL first to invalidate the current cookies (if any).
133+ # Additionally, we have to disable JS injection for the first load, as otherwise the user
134+ # will get an error for some reason.
135+ url = logout_url
136+ api .inject_js = False
137+
127138 logger .info ('Opening Epic Games login window...' )
139+ # Open logout URL first to remove existing cookies, then redirect to login.
128140 window = webview .create_window (f'Legendary { __version__ } - Epic Games Account Login' ,
129- url = logout_url if not callback_sid else login_url ,
130- width = 768 , height = 1024 , js_api = api )
141+ url = url , width = 768 , height = 1024 , js_api = api )
131142 api .window = window
132143 window .events .loaded += api .on_loaded
133144
0 commit comments