mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 19:55:53 +02: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:
@@ -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,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user