mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #7146 Better RTL handling on (de-)authentication
- RTL is applied (or unapplied) on login and logout depending on user language/guest-detected language. - config is automatically saved into res.locals.config whenever loadConfig is called - On login/logout, buildHeader is called instead of getting config - On logout, req.uid is deleted instead of set to 0
This commit is contained in:
@@ -124,6 +124,10 @@ app.cacheBuster = null;
|
|||||||
config = data.config;
|
config = data.config;
|
||||||
Benchpress.setGlobal('config', config);
|
Benchpress.setGlobal('config', config);
|
||||||
|
|
||||||
|
var htmlEl = $('html');
|
||||||
|
htmlEl.attr('data-dir', data.header.languageDirection);
|
||||||
|
htmlEl.css('direction', data.header.languageDirection);
|
||||||
|
|
||||||
// Manually reconnect socket.io
|
// Manually reconnect socket.io
|
||||||
socket.close();
|
socket.close();
|
||||||
socket.open();
|
socket.open();
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ apiController.loadConfig = function (req, callback) {
|
|||||||
config.bootswatchSkin = (meta.config.disableCustomUserSkins !== 1 && settings.bootswatchSkin && settings.bootswatchSkin !== '') ? settings.bootswatchSkin : '';
|
config.bootswatchSkin = (meta.config.disableCustomUserSkins !== 1 && settings.bootswatchSkin && settings.bootswatchSkin !== '') ? settings.bootswatchSkin : '';
|
||||||
plugins.fireHook('filter:config.get', config, next);
|
plugins.fireHook('filter:config.get', config, next);
|
||||||
},
|
},
|
||||||
|
function (config, next) {
|
||||||
|
req.res.locals.config = config;
|
||||||
|
process.nextTick(next, null, config);
|
||||||
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ var privileges = require('../privileges');
|
|||||||
var sockets = require('../socket.io');
|
var sockets = require('../socket.io');
|
||||||
|
|
||||||
var authenticationController = module.exports;
|
var authenticationController = module.exports;
|
||||||
var apiController = require('./api');
|
|
||||||
|
|
||||||
authenticationController.register = function (req, res) {
|
authenticationController.register = function (req, res) {
|
||||||
var registrationType = meta.config.registrationType || 'normal';
|
var registrationType = meta.config.registrationType || 'normal';
|
||||||
@@ -286,10 +285,10 @@ function continueLogin(req, res, next) {
|
|||||||
} else {
|
} else {
|
||||||
delete req.query.lang;
|
delete req.query.lang;
|
||||||
|
|
||||||
async.parallel({
|
async.series({
|
||||||
doLogin: async.apply(authenticationController.doLogin, req, userData.uid),
|
doLogin: async.apply(authenticationController.doLogin, req, userData.uid),
|
||||||
|
buildHeader: async.apply(middleware.buildHeader, req, res),
|
||||||
header: async.apply(middleware.generateHeader, req, res, {}),
|
header: async.apply(middleware.generateHeader, req, res, {}),
|
||||||
config: async.apply(apiController.loadConfig, req),
|
|
||||||
}, function (err, payload) {
|
}, function (err, payload) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return helpers.noScriptErrors(req, res, err.message, 403);
|
return helpers.noScriptErrors(req, res, err.message, 403);
|
||||||
@@ -309,7 +308,7 @@ function continueLogin(req, res, next) {
|
|||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
next: destination,
|
next: destination,
|
||||||
header: payload.header,
|
header: payload.header,
|
||||||
config: payload.config,
|
config: res.locals.config,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -473,7 +472,7 @@ authenticationController.logout = function (req, res, next) {
|
|||||||
function (next) {
|
function (next) {
|
||||||
req.logout();
|
req.logout();
|
||||||
req.session.regenerate(function (err) {
|
req.session.regenerate(function (err) {
|
||||||
req.uid = 0;
|
delete req.uid;
|
||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -490,9 +489,9 @@ authenticationController.logout = function (req, res, next) {
|
|||||||
if (req.body.noscript === 'true') {
|
if (req.body.noscript === 'true') {
|
||||||
res.redirect(nconf.get('relative_path') + '/');
|
res.redirect(nconf.get('relative_path') + '/');
|
||||||
} else {
|
} else {
|
||||||
async.parallel({
|
async.series({
|
||||||
|
buildHeader: async.apply(middleware.buildHeader, req, res),
|
||||||
header: async.apply(middleware.generateHeader, req, res, {}),
|
header: async.apply(middleware.generateHeader, req, res, {}),
|
||||||
config: async.apply(apiController.loadConfig, req),
|
|
||||||
}, function (err, payload) {
|
}, function (err, payload) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(500);
|
return res.status(500);
|
||||||
@@ -500,7 +499,7 @@ authenticationController.logout = function (req, res, next) {
|
|||||||
|
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
header: payload.header,
|
header: payload.header,
|
||||||
config: payload.config,
|
config: res.locals.config,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ module.exports = function (middleware) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
res.locals.config = results.config;
|
// Return no arguments
|
||||||
next();
|
setImmediate(next);
|
||||||
},
|
},
|
||||||
], next);
|
], next);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user