/**
* Change password middlewares.
*/
-
+
exports.validateChangePasswd = function(req, res, next) {
if (!req.session.user || req.body.oldpassword === undefined ||
req.body.newpassword === undefined) {
return res.send(400);
}
-
+
var errors = {};
if (req.body.oldpassword.trim() === '') {
else if(req.body.newpassword === req.body.oldpassword) {
errors.newpassword = "can't be changed to the old one";
}
-
+
if (errors.oldpassword || errors.newpassword) {
req.session.errors = errors;
return res.redirect(req.url);
}
-
+
next();
};
if (req.body.password.trim() === '') {
errors.password = "can't be empty";
}
-
+
req.session.oldvalues = {username: req.body.username};
if (errors.username || errors.password) {
req.session.errors = errors;
if (req.body.captcha !== req.session.captchacode) {
errors.captcha = 'no match';
}
-
+
// Save old values to repopulate the fields in case of future errors
req.session.oldvalues = {
username: req.body.username,
email: req.body.email
};
-
+
if (errors.username || errors.email || errors.password || errors.captcha) {
req.session.errors = errors;
return res.redirect(req.url);
}
-
+
next();
};
/**
* Recover password middlewares.
*/
-
+
exports.validateRecoverPasswd = function(req, res, next) {
if (req.body.email === undefined || req.body.captcha === undefined) {
return res.send(400);
}
var errors = {};
-
+
if (!utils.isEmail(req.body.email)) {
errors.email = 'is not an email address';
}
if (req.body.captcha !== req.session.captchacode) {
errors.captcha = 'no match';
}
-
+
req.session.oldvalues = {email: req.body.email};
-
+
if (errors.email || errors.captcha) {
req.session.errors = errors;
return res.redirect(req.url);
}
-
+
next();
};
if (req.body.password === undefined) {
return res.send(400);
}
-
+
var errors = {};
-
+
// Validate new password
if (req.body.password.trim() === '') {
errors.password = "can't be empty";
if (!req.query.token) {
errors.alert = 'Missing token.';
}
-
+
if (errors.password || errors.alert) {
req.session.errors = errors;
return res.redirect(req.url);
}
-
+
var key = 'token:' + req.query.token;
db.get([key], function(err, user) {
if (err) {
footer
#footer-inner
#copy © 2012-2014 Luigi Pinca
- iframe#facebook-button(allowTransparency="true", frameborder="0", scrolling="no",
+ iframe#facebook-button(allowTransparency="true", frameborder="0", scrolling="no",
src!="//www.facebook.com/plugins/like.php?action=like&colorscheme=light&href=http%3A%2F%2Fbinb.nodejitsu.com&layout=button_count&locale=en_US&share=true&show_faces=false")
iframe#twitter-button(allowtransparency="true", frameborder="0", scrolling="no",
src="//platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fbinb.nodejitsu.com")
- iframe#github-button(allowtransparency="true", frameborder="0", scrolling="0",
+ iframe#github-button(allowtransparency="true", frameborder="0", scrolling="0",
src="http://ghbtns.com/github-btn.html?user=lpinca&repo=binb&type=watch&count=true")
span.footer-info . Optimized for Google Chrome.
a#nodejitsu-logo.icons(target="_blank", href="http://nodejitsu.com/")
(function() {
var uv = document.createElement('script');
uv.type = 'text/javascript'; uv.async = true;
- uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
+ uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'widget.uservoice.com/LSMjFAQRifhD6BjOG2KWw.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(uv, s);