From c8ee1b4c5849e3950deda695c446380fb1510ad8 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 26 Feb 2016 16:45:44 +0200 Subject: [PATCH 1/4] closes #4261 --- src/controllers/authentication.js | 65 +++++++++++++++++-------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 841be5cceb..fa6cc6fd8c 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -87,8 +87,7 @@ function registerAndLoginUser(req, res, userData, callback) { function(_uid, next) { uid = _uid; if (res.locals.processLogin === true) { - user.logIP(uid, req.ip); - req.login({uid: uid}, next); + doLogin(req, uid, next); } else { next(); } @@ -172,37 +171,11 @@ function continueLogin(req, res, next) { res.status(200).send(nconf.get('relative_path') + '/reset/' + code); }); } else { - req.login({ - uid: userData.uid - }, function(err) { + doLogin(req, userData.uid, function(err) { if (err) { return res.status(403).send(err.message); } - if (userData.uid) { - var uuid = utils.generateUUID(); - req.session.meta = {}; - - // Associate IP used during login with user account - user.logIP(userData.uid, req.ip); - req.session.meta.ip = req.ip; - - // Associate metadata retrieved via user-agent - req.session.meta = _.extend(req.session.meta, { - uuid: uuid, - datetime: Date.now(), - platform: req.useragent.platform, - browser: req.useragent.browser, - version: req.useragent.version - }); - - // Associate login session with user - user.auth.addSession(userData.uid, req.sessionID); - db.setObjectField('uid:' + userData.uid + 'sessionUUID:sessionId', uuid, req.sessionID); - - plugins.fireHook('action:user.loggedIn', userData.uid); - } - if (!req.session.returnTo) { res.status(200).send(nconf.get('relative_path') + '/'); } else { @@ -216,6 +189,40 @@ function continueLogin(req, res, next) { })(req, res, next); } +function doLogin(req, uid, callback) { + req.login({uid: uid}, function(err) { + if (err) { + return callback(err); + } + + if (uid) { + var uuid = utils.generateUUID(); + req.session.meta = {}; + + // Associate IP used during login with user account + user.logIP(uid, req.ip); + req.session.meta.ip = req.ip; + + // Associate metadata retrieved via user-agent + req.session.meta = _.extend(req.session.meta, { + uuid: uuid, + datetime: Date.now(), + platform: req.useragent.platform, + browser: req.useragent.browser, + version: req.useragent.version + }); + + // Associate login session with user + user.auth.addSession(uid, req.sessionID); + db.setObjectField('uid:' + uid + 'sessionUUID:sessionId', uuid, req.sessionID); + + plugins.fireHook('action:user.loggedIn', uid); + } + + callback(); + }); +} + authenticationController.localLogin = function(req, username, password, next) { if (!username) { return next(new Error('[[error:invalid-username]]')); From 7ffbf35bcf024898dc25b24ee02d3eace09802f8 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 26 Feb 2016 17:06:03 +0200 Subject: [PATCH 2/4] closes #4273 --- public/src/client/register.js | 67 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/public/src/client/register.js b/public/src/client/register.js index f5096376c2..da86c0231d 100644 --- a/public/src/client/register.js +++ b/public/src/client/register.js @@ -1,6 +1,6 @@ 'use strict'; -/* globals define, app, utils, socket, config */ +/* globals define, app, utils, socket, config, ajaxify, bootbox */ define('forum/register', ['csrf', 'translator'], function(csrf, translator) { @@ -67,41 +67,44 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) { register.on('click', function(e) { var registerBtn = $(this); + var errorEl = $('#register-error-notify'); + errorEl.addClass('hidden'); e.preventDefault(); validateForm(function() { - if (!validationError) { - registerBtn.addClass('disabled'); - - registerBtn.parents('form').ajaxSubmit({ - headers: { - 'x-csrf-token': csrf.get() - }, - success: function(data, status) { - registerBtn.removeClass('disabled'); - if (!data) { - return; - } - if (data.referrer) { - window.location.href = data.referrer; - } else if (data.message) { - require(['translator'], function(translator) { - translator.translate(data.message, function(msg) { - bootbox.alert(msg); - ajaxify.go('/'); - }); + if (validationError) { + return; + } + + registerBtn.addClass('disabled'); + + registerBtn.parents('form').ajaxSubmit({ + headers: { + 'x-csrf-token': csrf.get() + }, + success: function(data) { + registerBtn.removeClass('disabled'); + if (!data) { + return; + } + if (data.referrer) { + window.location.href = data.referrer; + } else if (data.message) { + require(['translator'], function(translator) { + translator.translate(data.message, function(msg) { + bootbox.alert(msg); + ajaxify.go('/'); }); - } - }, - error: function(data, status) { - var errorEl = $('#register-error-notify'); - translator.translate(data.responseText, config.defaultLang, function(translated) { - errorEl.find('p').text(translated); - errorEl.show(); - registerBtn.removeClass('disabled'); }); } - }); - } + }, + error: function(data) { + translator.translate(data.responseText, config.defaultLang, function(translated) { + errorEl.find('p').text(translated); + errorEl.removeClass('hidden'); + registerBtn.removeClass('disabled'); + }); + } + }); }); }); @@ -181,6 +184,8 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) { if (password.length < ajaxify.data.minimumPasswordLength) { showError(password_notify, '[[user:change_password_error_length]]'); + } else if (password.length > 4096) { + showError(password_notify, '[[error:password-too-long]]'); } else if (!utils.isPasswordValid(password)) { showError(password_notify, '[[user:change_password_error]]'); } else if (password === $('#username').val()) { From 5f7cc00b44df122ae7aa18e2015d26583a123af7 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 26 Feb 2016 17:10:00 +0200 Subject: [PATCH 3/4] up themes --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5dcb5e8cf8..8774b80911 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "nodebb-plugin-spam-be-gone": "0.4.5", "nodebb-rewards-essentials": "0.0.6", "nodebb-theme-lavender": "3.0.8", - "nodebb-theme-persona": "4.0.86", - "nodebb-theme-vanilla": "5.0.51", + "nodebb-theme-persona": "4.0.87", + "nodebb-theme-vanilla": "5.0.52", "nodebb-widget-essentials": "2.0.6", "nodemailer": "2.0.0", "nodemailer-sendmail-transport": "1.0.0", From 7bc9e4439a198cb89c623d8822f7fd3007a5028d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 26 Feb 2016 12:37:51 -0500 Subject: [PATCH 4/4] removed .gitignore from list of sound files --- src/meta/sounds.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/meta/sounds.js b/src/meta/sounds.js index d13ecd70cd..4b85f681cb 100644 --- a/src/meta/sounds.js +++ b/src/meta/sounds.js @@ -38,6 +38,11 @@ module.exports = function(Meta) { ], function(err, files) { var localList = {}; + // Filter out hidden files + files = files.filter(function(filename) { + return !filename.startsWith('.'); + }); + if (err) { winston.error('Could not get local sound files:' + err.message); console.log(err.stack);