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-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",

@ -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()) {

@ -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]]'));

@ -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);

Loading…
Cancel
Save