Skip to content

Node.js based forum software built for the modern web

fix: #7146 Better RTL handling on (de-)authentication

Julian Lamd81e0a5f5bb9
diff --git a/public/src/app.js b/public/src/app.js
index 943eacf67a..bfc2fcbe89 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -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();
diff --git a/src/controllers/api.js b/src/controllers/api.js
index f90b2453f9..5f37721935 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -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);
};
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index e85c38e0f9..33272da695 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -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,
});
});
}
diff --git a/src/middleware/header.js b/src/middleware/header.js
index 9a9b89bba1..d90fcaedb4 100644
--- a/src/middleware/header.js
+++ b/src/middleware/header.js
@@ -44,8 +44,8 @@ module.exports = function (middleware) {
}, next);
},
function (results, next) {
- res.locals.config = results.config;
- next();
+ // Return no arguments
+ setImmediate(next);
},
], next);
};