Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes bug where one could register with empty username or password.

After commit 48bf2d6 it became possible to register with an empty username
and/or password. In fact, the checks ensuring a value in the username and
password fields were referencing legacy classes and no longer working. I thus
changed to a horizontal form per Twitter Bootstrap documentation[0] and added
some validation states informing the user of what is wrong.

[0]: http://getbootstrap.com/2.3.2/base-css.html#forms
  • Loading branch information...
commit 0a7a0f686b78cf8bb1992b74fed2c25f57c4740b 1 parent 2b151f1
@hermansc hermansc authored
Showing with 36 additions and 23 deletions.
  1. +12 −11 assets/js/views/overview.js
  2. +24 −12 views/templates.jade
View
23 assets/js/views/overview.js
@@ -134,26 +134,27 @@ var OverviewView = Backbone.View.extend({
var username = $('#' + action + '-username').val();
var password = $('#' + action + '-password').val();
-
+
if (!username) {
- $('#' + action + '-username').closest('.clearfix').addClass('error');
- $('#' + action + '-username').addClass('error');
+ $('#' + action + '-username').closest('.control-group').addClass('error');
+ $('#' + action + '-username').siblings('.help-inline').show();
}
if (!password) {
- $('#' + action + '-password').closest('.clearfix').addClass('error');
- $('#login-password').addClass('error');
+ $('#' + action + '-password').closest('.control-group').addClass('error');
+ $('#' + action + '-password').siblings('.help-inline').show();
}
if(username && password){
- $('form').append(ich.load_image());
+ $('#' + action + '-button').parent().append(ich.load_image());
$('#' + action + '-button').addClass('disabled');
+
+ // Everything looks OK with the form, send it to server-side.
+ irc.socket.emit(action, {
+ username: username,
+ password: password
+ });
}
-
- irc.socket.emit(action, {
- username: username,
- password: password
- });
},
toggle_ssl_options: function(event) {
View
36 views/templates.jade
@@ -110,26 +110,38 @@ script(id="overview_settings", type="text/html")
script(id="overview_login", type="text/html")
#home_parent
a.overview_button#home Home
- form.form-inline
+ form.form-horizontal
+ .control-group
+ label.control-label(for="login-username") Username
+ .controls
+ input#login-username(type="text")
+ span.help-inline(style="display:none") Please enter your username
.control-group
- label(for="login-username") Username
- input#login-username(type="text")
+ label.control-label(for="login-password") Password
+ .controls
+ input#login-password(type="password")
+ span.help-inline(style="display:none") Plase enter a password
.control-group
- label(for="login-password") Password
- input#login-password(type="password")
- a(id="login-button", class="btn btn-primary", type="submit") Login
+ .controls
+ a(id="login-button", class="btn btn-primary", type="submit") Login
script(id="overview_register", type="text/html")
#home_parent
a.overview_button#home Home
- form.form-inline
+ form.form-horizontal
+ .control-group
+ label.control-label(for="register-username") Username
+ .controls
+ input#register-username(type="text")
+ span.help-inline(style="display:none") Please enter your username
.control-group
- label(for="register-username") Username
- input#register-username(type="text")
+ label.control-label(for="register-password") Password
+ .controls
+ input#register-password(type="password")
+ span.help-inline(style="display:none") Please enter a password
.control-group
- label(for="register-password") Password
- input#register-password(type="password")
- a(id="register-button", class="btn btn-primary", type="button") Register
+ .controls
+ a(id="register-button", class="btn btn-primary", type="button") Register
script(id="titlebar", type="text/html")
.titlebar
Please sign in to comment.
Something went wrong with that request. Please try again.