diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 76d7f015..bf9f2e75 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -284,6 +284,7 @@ class AppWindow: self.button['state'] = self.theme_button['state'] = tk.DISABLED self.w.update_idletasks() try: + self.view_menu.entryconfigure(0, state=tk.DISABLED) # Status self.session.login(config.get('username'), config.get('password')) self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status self.status['text'] = '' diff --git a/companion.py b/companion.py index 9587c8af..86f24881 100644 --- a/companion.py +++ b/companion.py @@ -170,17 +170,14 @@ class Session: def login(self, username=None, password=None): if (not username or not password): - if not self.credentials: - raise CredentialsError() - elif self.state == Session.STATE_OK: - return # already logged in - else: - credentials = { 'email' : username, 'password' : password } - if self.credentials == credentials and self.state == Session.STATE_OK: - return # already logged in - else: - self.credentials = credentials - self.state = Session.STATE_INIT + raise CredentialsError() + credentials = { 'email' : username, 'password' : password } + if self.credentials == credentials and self.state == Session.STATE_OK: + return # already logged in + if self.credentials and self.credentials['email'] != credentials['email']: # changed account + self.session.cookies.clear() + self.credentials = credentials + self.state = Session.STATE_INIT try: r = self.session.post(URL_LOGIN, data = self.credentials, timeout=timeout) except: