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;
|
||||
Benchpress.setGlobal('config', config);
|
||||
|
||||
var htmlEl = $('html');
|
||||
htmlEl.attr('data-dir', data.header.languageDirection);
|
||||
htmlEl.css('direction', data.header.languageDirection);
|
||||
|
||||
// Manually reconnect socket.io
|
||||
socket.close();
|
||||
socket.open();
|
||||
|
||||
@@ -101,6 +101,10 @@ apiController.loadConfig = function (req, callback) {
|
||||
config.bootswatchSkin = (meta.config.disableCustomUserSkins !== 1 && settings.bootswatchSkin && settings.bootswatchSkin !== '') ? settings.bootswatchSkin : '';
|
||||
plugins.fireHook('filter:config.get', config, next);
|
||||
},
|
||||
function (config, next) {
|
||||
req.res.locals.config = config;
|
||||
process.nextTick(next, null, config);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ var privileges = require('../privileges');
|
||||
var sockets = require('../socket.io');
|
||||
|
||||
var authenticationController = module.exports;
|
||||
var apiController = require('./api');
|
||||
|
||||
authenticationController.register = function (req, res) {
|
||||
var registrationType = meta.config.registrationType || 'normal';
|
||||
@@ -286,10 +285,10 @@ function continueLogin(req, res, next) {
|
||||
} else {
|
||||
delete req.query.lang;
|
||||
|
||||
async.parallel({
|
||||
async.series({
|
||||
doLogin: async.apply(authenticationController.doLogin, req, userData.uid),
|
||||
buildHeader: async.apply(middleware.buildHeader, req, res),
|
||||
header: async.apply(middleware.generateHeader, req, res, {}),
|
||||
config: async.apply(apiController.loadConfig, req),
|
||||
}, function (err, payload) {
|
||||
if (err) {
|
||||
return helpers.noScriptErrors(req, res, err.message, 403);
|
||||
@@ -309,7 +308,7 @@ function continueLogin(req, res, next) {
|
||||
res.status(200).send({
|
||||
next: destination,
|
||||
header: payload.header,
|
||||
config: payload.config,
|
||||
config: res.locals.config,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -473,7 +472,7 @@ authenticationController.logout = function (req, res, next) {
|
||||
function (next) {
|
||||
req.logout();
|
||||
req.session.regenerate(function (err) {
|
||||
req.uid = 0;
|
||||
delete req.uid;
|
||||
next(err);
|
||||
});
|
||||
},
|
||||
@@ -490,9 +489,9 @@ authenticationController.logout = function (req, res, next) {
|
||||
if (req.body.noscript === 'true') {
|
||||
res.redirect(nconf.get('relative_path') + '/');
|
||||
} else {
|
||||
async.parallel({
|
||||
async.series({
|
||||
buildHeader: async.apply(middleware.buildHeader, req, res),
|
||||
header: async.apply(middleware.generateHeader, req, res, {}),
|
||||
config: async.apply(apiController.loadConfig, req),
|
||||
}, function (err, payload) {
|
||||
if (err) {
|
||||
return res.status(500);
|
||||
@@ -500,7 +499,7 @@ authenticationController.logout = function (req, res, next) {
|
||||
|
||||
res.status(200).send({
|
||||
header: payload.header,
|
||||
config: payload.config,
|
||||
config: res.locals.config,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ module.exports = function (middleware) {
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
res.locals.config = results.config;
|
||||
next();
|
||||
// Return no arguments
|
||||
setImmediate(next);
|
||||
},
|
||||
], next);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user