Skip to content

Commit 69b077d

Browse files
committed
fix(client): clear cookies on login, logout, register
We should be clearing all cookies, since we can only be logged into a single user and cluster at the same time. This fixes the 403 Forbidden when being logged in immediately after registering.
1 parent 58a4db7 commit 69b077d

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

client/deis.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,7 @@ def __init__(self):
9090
if os.path.isfile(cookie_file):
9191
self.cookies.load()
9292
self.cookies.clear_expired_cookies()
93-
94-
def clear(self, domain):
95-
"""Clear cookies for the specified domain."""
96-
try:
97-
self.cookies.clear(domain)
9893
self.cookies.save()
99-
except KeyError:
100-
pass
10194

10295
def git_root(self):
10396
"""
@@ -629,6 +622,9 @@ def auth_register(self, args):
629622
email = raw_input('email: ')
630623
url = urlparse.urljoin(controller, '/api/auth/register')
631624
payload = {'username': username, 'password': password, 'email': email}
625+
# Clear any existing cookies
626+
self._session.cookies.clear()
627+
self._session.cookies.save()
632628
response = self._session.post(url, data=payload, allow_redirects=False)
633629
if response.status_code == requests.codes.created: # @UndefinedVariable
634630
self._settings['controller'] = controller
@@ -685,8 +681,9 @@ def auth_login(self, args):
685681
password = getpass('password: ')
686682
url = urlparse.urljoin(controller, '/api/auth/login/')
687683
payload = {'username': username, 'password': password}
688-
# clear any cookies for this controller's domain
689-
self._session.clear(urlparse.urlparse(url).netloc)
684+
# clear any existing cookies
685+
self._session.cookies.clear()
686+
self._session.cookies.save()
690687
# prime cookies for login
691688
self._session.get(url, headers=headers)
692689
# post credentials to the login URL
@@ -697,8 +694,6 @@ def auth_login(self, args):
697694
print("Logged in as {}".format(username))
698695
return username
699696
else:
700-
self._session.cookies.clear()
701-
self._session.cookies.save()
702697
raise ResponseError(response)
703698

704699
def auth_logout(self, args):

0 commit comments

Comments
 (0)