From 99108c750af3c9dd9279f9c60b589bc7d60a5a05 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 17 Mar 2014 14:45:08 -0400 Subject: [PATCH 1/6] don't refresh widgets on every new post --- public/src/forum/category.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 7fe306bdbf..d9035594b8 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -178,7 +178,12 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { numTopics = topics.length; $('#topics-container, .category-sidebar').removeClass('hidden'); - $('#category-no-topics').remove(); + + var noTopicsWarning = $('#category-no-topics'); + if (noTopicsWarning.length) { + noTopicsWarning.remove(); + ajaxify.renderWidgets('category', window.location.pathname.slice(1)); + } if (numTopics > 0) { for (var x = 0; x < numTopics; x++) { @@ -204,10 +209,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { topic.find('span.timeago').timeago(); app.createUserTooltips(); - - ajaxify.renderWidgets('category', window.location.pathname.slice(1), function() { - $(window).trigger('action:categories.new_topic.loaded'); - }); + $(window).trigger('action:categories.new_topic.loaded'); }); }); }; From cd4a204f999d5ef5bac4557f03d4c15abebfdce3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 17 Mar 2014 14:56:00 -0400 Subject: [PATCH 2/6] closes #963 --- src/routes/authentication.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index b2ffd4f73d..28f46ec7b5 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -59,14 +59,29 @@ }); })(req, res, next); } - + function register(req, res) { if(meta.config.allowRegistration !== undefined && parseInt(meta.config.allowRegistration, 10) === 0) { return res.send(403); } - user.create({username: req.body.username, password: req.body.password, email: req.body.email, ip: req.ip}, function(err, uid) { - if (err === null && uid) { + var userData = { + username: req.body.username, + password: req.body.password, + email: req.body.email, + ip: req.ip + }; + + plugins.fireHook('filter:register.check', userData, function(err, userData) { + if (err) { + res.redirect(nconf.get('relative_path') + '/register'); + } + + user.create(userData, function(err, uid) { + if (err || !uid) { + res.redirect(nconf.get('relative_path') + '/register'); + } + req.login({ uid: uid }, function() { @@ -79,9 +94,7 @@ res.redirect(nconf.get('relative_path') + '/'); } }); - } else { - res.redirect(nconf.get('relative_path') + '/register'); - } + }); }); } From 76d8f19e73041560de9914bc0b76314231b5e9fa Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 17 Mar 2014 14:56:32 -0400 Subject: [PATCH 3/6] forgot to return #963 --- src/routes/authentication.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 28f46ec7b5..1b35d78d29 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -74,12 +74,12 @@ plugins.fireHook('filter:register.check', userData, function(err, userData) { if (err) { - res.redirect(nconf.get('relative_path') + '/register'); + return res.redirect(nconf.get('relative_path') + '/register'); } user.create(userData, function(err, uid) { if (err || !uid) { - res.redirect(nconf.get('relative_path') + '/register'); + return res.redirect(nconf.get('relative_path') + '/register'); } req.login({ From 653007b72e42bc5a8b6fbdb4881210199f64ecdb Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 17 Mar 2014 15:15:16 -0400 Subject: [PATCH 4/6] closes #1231 --- public/src/ajaxify.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index ccf35aa214..79d1482860 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -191,6 +191,7 @@ var ajaxify = {}; } } + $('#content [widget-area] img').addClass('img-responsive') checkCallback(); }); } From da7d6a31374e9ca9b6c8a1cef67ec3703a40ba8a Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 17 Mar 2014 15:38:06 -0400 Subject: [PATCH 5/6] closes #1175 --- public/language/en_GB/login.json | 2 +- src/routes/authentication.js | 11 ++++++++++- src/user.js | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/public/language/en_GB/login.json b/public/language/en_GB/login.json index f2090276a1..9f910e58e4 100644 --- a/public/language/en_GB/login.json +++ b/public/language/en_GB/login.json @@ -1,6 +1,6 @@ { "login": "Login", - "username": "Username", + "username": "Username / Email", "password": "Password", "remember_me": "Remember Me?", "forgot_password": "Forgot Password?", diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 1b35d78d29..ad85141c75 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -134,8 +134,17 @@ } app.post('/logout', logout); - app.post('/login', login); app.post('/register', register); + app.post('/login', function(req, res, next) { + if (req.body.username && utils.isEmailValid(req.body.username)) { + user.getUsernameByEmail(req.body.username, function(err, username) { + req.body.username = username ? username : req.body.username; + login(req, res, next); + }); + } else { + login(req, res, next); + } + }); }); }); }; diff --git a/src/user.js b/src/user.js index 5249a9b4e0..6d72f43020 100644 --- a/src/user.js +++ b/src/user.js @@ -412,6 +412,12 @@ var bcrypt = require('bcryptjs'), db.getObjectField('email:uid', email, callback); }; + User.getUsernameByEmail = function(email, callback) { + db.getObjectField('email:uid', email, function(err, uid) { + User.getUserField(uid, 'username', callback); + }); + }; + User.isModerator = function(uid, cid, callback) { groups.isMemberByGroupName(uid, 'cid:' + cid + ':privileges:mods', callback); }; From e49d445422d6d0e863fdb4df7fd6a75cb43ec07e Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 17 Mar 2014 15:46:53 -0400 Subject: [PATCH 6/6] added err checking --- src/routes/authentication.js | 3 +++ src/user.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index ad85141c75..60e54c0c57 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -138,6 +138,9 @@ app.post('/login', function(req, res, next) { if (req.body.username && utils.isEmailValid(req.body.username)) { user.getUsernameByEmail(req.body.username, function(err, username) { + if (err) { + return next(err); + } req.body.username = username ? username : req.body.username; login(req, res, next); }); diff --git a/src/user.js b/src/user.js index 6d72f43020..6abb142547 100644 --- a/src/user.js +++ b/src/user.js @@ -414,6 +414,9 @@ var bcrypt = require('bcryptjs'), User.getUsernameByEmail = function(email, callback) { db.getObjectField('email:uid', email, function(err, uid) { + if (err) { + return callback(err); + } User.getUserField(uid, 'username', callback); }); };