From 7ab92dd62acf90a644fec3c620146ad6ae5622f7 2011-11-18 20:04:17
From: Stefan van der Walt <stefan@sun.ac.za>
Date: 2011-11-18 20:04:17
Subject: [PATCH] Notify user about invalid password.

---

diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py
index d6c5b19..7822118 100644
--- a/IPython/frontend/html/notebook/handlers.py
+++ b/IPython/frontend/html/notebook/handlers.py
@@ -167,17 +167,25 @@ class ProjectDashboardHandler(AuthenticatedHandler):
 
 class LoginHandler(AuthenticatedHandler):
 
-    def get(self):
+    def _render(self, message=''):
         self.render('login.html',
                 next=self.get_argument('next', default='/'),
                 read_only=self.read_only,
+                message=message
         )
 
+    def get(self):
+        self._render()
+
     def post(self):
         pwd = self.get_argument('password', default=u'')
-        if self.application.password and \
-               passwd_check(self.application.password, pwd):
-            self.set_secure_cookie('username', str(uuid.uuid4()))
+        if self.application.password:
+            if passwd_check(self.application.password, pwd):
+                self.set_secure_cookie('username', str(uuid.uuid4()))
+            else:
+                self._render(message='Invalid password')
+                return
+
         self.redirect(self.get_argument('next', default='/'))
 
 
diff --git a/IPython/frontend/html/notebook/static/css/layout.css b/IPython/frontend/html/notebook/static/css/layout.css
index e80cca1..b9e0b08 100644
--- a/IPython/frontend/html/notebook/static/css/layout.css
+++ b/IPython/frontend/html/notebook/static/css/layout.css
@@ -101,3 +101,15 @@
 	-moz-box-pack: center;
 	box-pack: center;
 }
+
+#message {
+    border: 1px solid red;
+    background-color: #FFD3D1;
+    text-align: center;
+    padding: 0.5em;
+    margin: 0.5em;
+}
+
+#content_panel {
+    margin: 0.5em;
+}
\ No newline at end of file
diff --git a/IPython/frontend/html/notebook/static/css/projectdashboard.css b/IPython/frontend/html/notebook/static/css/projectdashboard.css
index 9d73096..0ca7484 100644
--- a/IPython/frontend/html/notebook/static/css/projectdashboard.css
+++ b/IPython/frontend/html/notebook/static/css/projectdashboard.css
@@ -31,7 +31,7 @@ body {
 }
 
 #content_toolbar {
-    padding: 10px 5px 5px 5px;
+    padding: 5px;
     height: 25px;
     line-height: 25px;
 }
diff --git a/IPython/frontend/html/notebook/templates/login.html b/IPython/frontend/html/notebook/templates/login.html
index 03b7b1c..b719c5b 100644
--- a/IPython/frontend/html/notebook/templates/login.html
+++ b/IPython/frontend/html/notebook/templates/login.html
@@ -31,6 +31,12 @@
     </div>
     
     <div id="content_panel">
+        {% if message %}
+        <div id="message">
+            {{message}}
+        </div>
+        {% end %}
+
         <form action="/login?next={{url_escape(next)}}" method="post">
             Password: <input type="password" name="password">
             <input type="submit" value="Sign in" id="signin">