Handle bad login credentials
authorJakob <jakob@jcornell.net>
Tue, 3 Dec 2019 05:08:49 +0000 (23:08 -0600)
committerJakob <jakob@jcornell.net>
Tue, 3 Dec 2019 05:08:49 +0000 (23:08 -0600)
auth.py

diff --git a/auth.py b/auth.py
index 269991de52803e7523b098bc8141ca9cc3fa2713..e20a81ae4b2b8bb1f570e293085de5020b80359d 100644 (file)
--- 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):