From: Jakob Date: Tue, 3 Dec 2019 05:08:49 +0000 (-0600) Subject: Handle bad login credentials X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=a49506c79aac93648c76986c74946fbff893313f;p=bb-sync-api.git Handle bad login credentials --- diff --git a/auth.py b/auth.py index 269991d..e20a81a 100644 --- a/auth.py +++ b/auth.py @@ -283,8 +283,6 @@ class CookieAuthHandler(urllib.request.HTTPCookieProcessor): else: username = self.ui.ask_username() password = self.ui.ask_password() - self.storage_mgr['username'] = username - self.storage_mgr['password'] = encode(password) url = 'https://' + self.bb_root.host + str(self.bb_root.path) with self.parent.open(url) as resp: @@ -310,6 +308,12 @@ class CookieAuthHandler(urllib.request.HTTPCookieProcessor): with self.parent.open(req) as resp: resp.read() + if resp.url.endswith('/webapps/login'): + log('error', "Login failed. Are your credentials correct?") + else: + self.storage_mgr['username'] = username + self.storage_mgr['password'] = encode(password) + self.cookiejar.save() def http_error_401(self, request, fp, code, msg, headers):