v1.18.x
Barış Soner Uşaklı 7 years ago
parent e7a6326b2f
commit fd78eb6d57

@ -9,7 +9,9 @@ app.widgets = {};
app.cacheBuster = null; app.cacheBuster = null;
(function () { (function () {
var showWelcomeMessage = !!utils.params().loggedin; var params = utils.params();
var showWelcomeMessage = !!params.loggedin;
var registerMessage = params.register;
require(['benchpress'], function (Benchpress) { require(['benchpress'], function (Benchpress) {
Benchpress.setGlobal('config', config); Benchpress.setGlobal('config', config);
@ -286,9 +288,12 @@ app.cacheBuster = null;
title: '[[global:welcome_back]] ' + app.user.username + '!', title: '[[global:welcome_back]] ' + app.user.username + '!',
message: '[[global:you_have_successfully_logged_in]]', message: '[[global:you_have_successfully_logged_in]]',
}, },
register: {
format: 'modal',
},
}; };
function showAlert(type) { function showAlert(type, message) {
switch (messages[type].format) { switch (messages[type].format) {
case 'alert': case 'alert':
app.alert({ app.alert({
@ -301,7 +306,7 @@ app.cacheBuster = null;
case 'modal': case 'modal':
require(['translator'], function (translator) { require(['translator'], function (translator) {
translator.translate(messages[type].message, function (translated) { translator.translate(message || messages[type].message, function (translated) {
bootbox.alert({ bootbox.alert({
title: messages[type].title, title: messages[type].title,
message: translated, message: translated,
@ -318,6 +323,12 @@ app.cacheBuster = null;
showAlert('login'); showAlert('login');
}); });
} }
if (registerMessage) {
$(document).ready(function () {
showAlert('register', decodeURIComponent(registerMessage));
registerMessage = false;
});
}
}; };
app.openChat = function (roomId, uid) { app.openChat = function (roomId, uid) {

@ -57,18 +57,7 @@ authenticationController.register = function (req, res) {
user.isPasswordValid(userData.password, next); user.isPasswordValid(userData.password, next);
}, },
function (next) { function (next) {
user.shouldQueueUser(req.ip, next); registerAndLoginUser(req, res, userData, next);
},
function (queue, next) {
res.locals.processLogin = true; // set it to false in plugin if you wish to just register only
plugins.fireHook('filter:register.check', { req: req, res: res, userData: userData, queue: queue }, next);
},
function (data, next) {
if (data.queue) {
addToApprovalQueue(req, userData, next);
} else {
registerAndLoginUser(req, res, userData, next);
}
}, },
], function (err, data) { ], function (err, data) {
if (err) { if (err) {
@ -108,7 +97,18 @@ function registerAndLoginUser(req, res, userData, callback) {
return res.json({ referrer: nconf.get('relative_path') + '/register/complete' }); return res.json({ referrer: nconf.get('relative_path') + '/register/complete' });
}, },
function (next) { function (next) {
user.create(userData, next); user.shouldQueueUser(req.ip, next);
},
function (queue, next) {
res.locals.processLogin = true; // set it to false in plugin if you wish to just register only
plugins.fireHook('filter:register.check', { req: req, res: res, userData: userData, queue: queue }, next);
},
function (data, next) {
if (data.queue) {
addToApprovalQueue(req, userData, callback);
} else {
user.create(userData, next);
}
}, },
function (_uid, next) { function (_uid, next) {
uid = _uid; uid = _uid;
@ -155,9 +155,11 @@ authenticationController.registerComplete = function (req, res, next) {
return memo; return memo;
}, []); }, []);
var done = function () { var done = function (err, data) {
delete req.session.registration; delete req.session.registration;
if (!err && data && data.message) {
return res.redirect(nconf.get('relative_path') + '/?register=' + encodeURIComponent(data.message));
}
if (req.session.returnTo) { if (req.session.returnTo) {
res.redirect(req.session.returnTo); res.redirect(req.session.returnTo);
} else { } else {

Loading…
Cancel
Save