Permalink
Browse files

Notify user about invalid password.

  • Loading branch information...
1 parent 8e03291 commit 7ab92dd62acf90a644fec3c620146ad6ae5622f7 @stefanv stefanv committed Nov 18, 2011
@@ -167,17 +167,25 @@ def get(self):
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='/'))
@@ -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;
+}
@@ -31,7 +31,7 @@ body {
}
#content_toolbar {
- padding: 10px 5px 5px 5px;
+ padding: 5px;
height: 25px;
line-height: 25px;
}
@@ -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">

0 comments on commit 7ab92dd

Please sign in to comment.