]> git.example.dev Git - binbsis50.git/commitdiff
minor tweaks and fixes
authorLuigi Pinca <luigipinca@gmail.com>
Sat, 25 May 2013 08:21:30 +0000 (10:21 +0200)
committerLuigi Pinca <luigipinca@gmail.com>
Sat, 25 May 2013 08:21:30 +0000 (10:21 +0200)
package.json
routes/user.js
views/changepasswd.jade

index cec56e1097414fb20889f25f1635b4016e107dd5..d417e90841c93aaa6ea2a813a1fddfd84bd04767 100644 (file)
@@ -8,7 +8,7 @@
     "canvas": "1.0.x",
     "connect-redis": "1.4.x",
     "express": "3.2.x",
-    "jade": "0.29.x",
+    "jade": "0.30.x",
     "nodemailer": "0.4.x",
     "redis": "0.7.x",
     "socket.io": "0.9.x"
@@ -25,5 +25,5 @@
     "start": "node app.js"
   },
   "subdomain": "binb",
-  "version": "0.3.6-3"
+  "version": "0.3.6-5"
 }
index 1607042d9bbc48886c9d77d87192c3531729f5f3..7a6955e07a0d0b5f0c2f2e96b05d50f5827651f8 100644 (file)
@@ -40,7 +40,7 @@ exports.sliceLeaderboard = function(req, res) {
   var begin = parseInt(req.query.begin, 10)
     , by = req.query.by;
   if (isNaN(begin) || begin > 180 || (by !== 'points' && by !== 'times')) {
-    return res.send(412);
+    return res.send(400);
   }
   var end = begin + 29;
   if (by === 'points') {
@@ -61,7 +61,7 @@ exports.sliceLeaderboard = function(req, res) {
 exports.validateChangePasswd = function(req, res, next) {
   if (!req.session.user || req.body.oldpassword === undefined ||
     req.body.newpassword === undefined) {
-    return res.send(412);
+    return res.send(400);
   }
   
   var errors = {};
@@ -69,7 +69,10 @@ exports.validateChangePasswd = function(req, res, next) {
   if (req.body.oldpassword.trim() === '') {
     errors.oldpassword = "can't be empty";
   }
-  if (req.body.newpassword.length < 6) {
+  if (req.body.newpassword.trim() === '') {
+    errors.newpassword = "can't be empty";
+  }
+  else if (req.body.newpassword.length < 6) {
     errors.newpassword = 'must be at least 6 characters long';
   }
   else if(req.body.newpassword === req.body.oldpassword) {
@@ -118,7 +121,7 @@ exports.changePasswd = function(req, res) {
 
 exports.validateLogin = function(req, res, next) {
   if (req.body.username === undefined || req.body.password === undefined) {
-    return res.send(412);
+    return res.send(400);
   }
 
   var errors = {};
@@ -187,7 +190,7 @@ exports.logout = function(req, res) {
 exports.validateSignUp = function(req, res, next) {
   if (req.body.username === undefined || req.body.email === undefined ||
     req.body.password === undefined || req.body.captcha === undefined) {
-    return res.send(412);
+    return res.send(400);
   }
 
   var errors = {};
@@ -201,7 +204,10 @@ exports.validateSignUp = function(req, res, next) {
   if (!utils.isEmail(req.body.email)) {
     errors.email = 'is not an email address';
   }
-  if (req.body.password.length < 6) {
+  if (req.body.password.trim() === '') {
+    errors.password = "can't be empty";
+  }
+  else if (req.body.password.length < 6) {
     errors.password = 'must be at least 6 characters long';
   }
   if (req.body.captcha !== req.session.captchacode) {
@@ -274,7 +280,7 @@ exports.createAccount = function(req, res) {
  
 exports.validateRecoverPasswd = function(req, res, next) {
   if (req.body.email === undefined || req.body.captcha === undefined) {
-    return res.send(412);
+    return res.send(400);
   }
 
   var errors = {};
@@ -329,13 +335,16 @@ exports.sendEmail = function(req, res) {
 
 exports.resetPasswd = function(req, res) {
   if (req.body.password === undefined) {
-    return res.send(412);
+    return res.send(400);
   }
   
   var errors = {};
   
   // Validate new password
-  if (req.body.password.length < 6) {
+  if (req.body.password.trim() === '') {
+    errors.password = "can't be empty";
+  }
+  else if (req.body.password.length < 6) {
     errors.password = 'must be at least 6 characters long';
   }
   // Check token availability
index 5af4d7dfc0774a31ec281b8bb5257a0f2f644bc2..2560c09852357f1268454e925f003e23b5defcc4 100644 (file)
@@ -55,7 +55,7 @@ block sections
                   input#oldpassword(type="password", name="oldpassword",
                     placeholder="enter your current password...")
               .control-group
-                label.control-label(for="password") New password
+                label.control-label(for="newpassword") New password
                 .controls
                   input#newpassword(type="password", name="newpassword",
                     placeholder="enter your new password...")