1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-20 08:44:07 +03:00

Clear cookies on changing username

Hopefully fixes #108
This commit is contained in:
Jonathan Harris 2016-04-19 16:26:52 +01:00
parent 6281490cdc
commit 9559a7a700
2 changed files with 9 additions and 11 deletions

View File

@ -284,6 +284,7 @@ class AppWindow:
self.button['state'] = self.theme_button['state'] = tk.DISABLED self.button['state'] = self.theme_button['state'] = tk.DISABLED
self.w.update_idletasks() self.w.update_idletasks()
try: try:
self.view_menu.entryconfigure(0, state=tk.DISABLED) # Status
self.session.login(config.get('username'), config.get('password')) self.session.login(config.get('username'), config.get('password'))
self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status
self.status['text'] = '' self.status['text'] = ''

View File

@ -170,17 +170,14 @@ class Session:
def login(self, username=None, password=None): def login(self, username=None, password=None):
if (not username or not password): if (not username or not password):
if not self.credentials: raise CredentialsError()
raise CredentialsError() credentials = { 'email' : username, 'password' : password }
elif self.state == Session.STATE_OK: if self.credentials == credentials and self.state == Session.STATE_OK:
return # already logged in return # already logged in
else: if self.credentials and self.credentials['email'] != credentials['email']: # changed account
credentials = { 'email' : username, 'password' : password } self.session.cookies.clear()
if self.credentials == credentials and self.state == Session.STATE_OK: self.credentials = credentials
return # already logged in self.state = Session.STATE_INIT
else:
self.credentials = credentials
self.state = Session.STATE_INIT
try: try:
r = self.session.post(URL_LOGIN, data = self.credentials, timeout=timeout) r = self.session.post(URL_LOGIN, data = self.credentials, timeout=timeout)
except: except: