Merge branch 'master' into fix-vendors

v1.18.x
Julian Lam 9 years ago
commit 432c3d777d

@ -54,8 +54,8 @@
"nodebb-plugin-spam-be-gone": "0.4.5", "nodebb-plugin-spam-be-gone": "0.4.5",
"nodebb-rewards-essentials": "0.0.6", "nodebb-rewards-essentials": "0.0.6",
"nodebb-theme-lavender": "3.0.8", "nodebb-theme-lavender": "3.0.8",
"nodebb-theme-persona": "4.0.86", "nodebb-theme-persona": "4.0.87",
"nodebb-theme-vanilla": "5.0.51", "nodebb-theme-vanilla": "5.0.52",
"nodebb-widget-essentials": "2.0.6", "nodebb-widget-essentials": "2.0.6",
"nodemailer": "2.0.0", "nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0", "nodemailer-sendmail-transport": "1.0.0",

@ -1,6 +1,6 @@
'use strict'; 'use strict';
/* globals define, app, utils, socket, config */ /* globals define, app, utils, socket, config, ajaxify, bootbox */
define('forum/register', ['csrf', 'translator'], function(csrf, translator) { define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
@ -67,16 +67,21 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
register.on('click', function(e) { register.on('click', function(e) {
var registerBtn = $(this); var registerBtn = $(this);
var errorEl = $('#register-error-notify');
errorEl.addClass('hidden');
e.preventDefault(); e.preventDefault();
validateForm(function() { validateForm(function() {
if (!validationError) { if (validationError) {
return;
}
registerBtn.addClass('disabled'); registerBtn.addClass('disabled');
registerBtn.parents('form').ajaxSubmit({ registerBtn.parents('form').ajaxSubmit({
headers: { headers: {
'x-csrf-token': csrf.get() 'x-csrf-token': csrf.get()
}, },
success: function(data, status) { success: function(data) {
registerBtn.removeClass('disabled'); registerBtn.removeClass('disabled');
if (!data) { if (!data) {
return; return;
@ -92,16 +97,14 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
}); });
} }
}, },
error: function(data, status) { error: function(data) {
var errorEl = $('#register-error-notify');
translator.translate(data.responseText, config.defaultLang, function(translated) { translator.translate(data.responseText, config.defaultLang, function(translated) {
errorEl.find('p').text(translated); errorEl.find('p').text(translated);
errorEl.show(); errorEl.removeClass('hidden');
registerBtn.removeClass('disabled'); registerBtn.removeClass('disabled');
}); });
} }
}); });
}
}); });
}); });
@ -181,6 +184,8 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
if (password.length < ajaxify.data.minimumPasswordLength) { if (password.length < ajaxify.data.minimumPasswordLength) {
showError(password_notify, '[[user:change_password_error_length]]'); 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)) { } else if (!utils.isPasswordValid(password)) {
showError(password_notify, '[[user:change_password_error]]'); showError(password_notify, '[[user:change_password_error]]');
} else if (password === $('#username').val()) { } else if (password === $('#username').val()) {

@ -87,8 +87,7 @@ function registerAndLoginUser(req, res, userData, callback) {
function(_uid, next) { function(_uid, next) {
uid = _uid; uid = _uid;
if (res.locals.processLogin === true) { if (res.locals.processLogin === true) {
user.logIP(uid, req.ip); doLogin(req, uid, next);
req.login({uid: uid}, next);
} else { } else {
next(); next();
} }
@ -172,19 +171,36 @@ function continueLogin(req, res, next) {
res.status(200).send(nconf.get('relative_path') + '/reset/' + code); res.status(200).send(nconf.get('relative_path') + '/reset/' + code);
}); });
} else { } else {
req.login({ doLogin(req, userData.uid, function(err) {
uid: userData.uid
}, function(err) {
if (err) { if (err) {
return res.status(403).send(err.message); return res.status(403).send(err.message);
} }
if (userData.uid) { if (!req.session.returnTo) {
res.status(200).send(nconf.get('relative_path') + '/');
} else {
var next = req.session.returnTo;
delete req.session.returnTo;
res.status(200).send(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(); var uuid = utils.generateUUID();
req.session.meta = {}; req.session.meta = {};
// Associate IP used during login with user account // Associate IP used during login with user account
user.logIP(userData.uid, req.ip); user.logIP(uid, req.ip);
req.session.meta.ip = req.ip; req.session.meta.ip = req.ip;
// Associate metadata retrieved via user-agent // Associate metadata retrieved via user-agent
@ -197,24 +213,15 @@ function continueLogin(req, res, next) {
}); });
// Associate login session with user // Associate login session with user
user.auth.addSession(userData.uid, req.sessionID); user.auth.addSession(uid, req.sessionID);
db.setObjectField('uid:' + userData.uid + 'sessionUUID:sessionId', uuid, req.sessionID); db.setObjectField('uid:' + uid + 'sessionUUID:sessionId', uuid, req.sessionID);
plugins.fireHook('action:user.loggedIn', userData.uid); plugins.fireHook('action:user.loggedIn', uid);
} }
if (!req.session.returnTo) { callback();
res.status(200).send(nconf.get('relative_path') + '/');
} else {
var next = req.session.returnTo;
delete req.session.returnTo;
res.status(200).send(next);
}
}); });
} }
})(req, res, next);
}
authenticationController.localLogin = function(req, username, password, next) { authenticationController.localLogin = function(req, username, password, next) {
if (!username) { if (!username) {

@ -38,6 +38,11 @@ module.exports = function(Meta) {
], function(err, files) { ], function(err, files) {
var localList = {}; var localList = {};
// Filter out hidden files
files = files.filter(function(filename) {
return !filename.startsWith('.');
});
if (err) { if (err) {
winston.error('Could not get local sound files:' + err.message); winston.error('Could not get local sound files:' + err.message);
console.log(err.stack); console.log(err.stack);

Loading…
Cancel
Save