From: Luigi Pinca Date: Sat, 25 May 2013 08:21:30 +0000 (+0200) Subject: minor tweaks and fixes X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=95a1049bbcf5600c829780ef041ce545dd4e8095;p=binbsis50.git minor tweaks and fixes --- diff --git a/package.json b/package.json index cec56e1..d417e90 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/routes/user.js b/routes/user.js index 1607042..7a6955e 100644 --- a/routes/user.js +++ b/routes/user.js @@ -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 diff --git a/views/changepasswd.jade b/views/changepasswd.jade index 5af4d7d..2560c09 100644 --- a/views/changepasswd.jade +++ b/views/changepasswd.jade @@ -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...")