test: passport0.6 (#10638)

* test: passport0.6

* test: make logout async, fix lint

* test: keepSessionInfo flag

* revert: csrf load
isekai-main
Barış Soner Uşaklı 3 years ago committed by GitHub
parent 4b6baabbbf
commit 6b2a6f9006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -104,7 +104,7 @@
"nodebb-widget-essentials": "6.0.0",
"nodemailer": "6.7.7",
"nprogress": "0.2.0",
"passport": "0.5.2",
"passport": "0.6.0",
"passport-http-bearer": "1.0.1",
"passport-local": "1.0.0",
"pg": "8.7.3",

@ -351,7 +351,7 @@ authenticationController.doLogin = async function (req, uid) {
}
}
await loginAsync({ uid: uid });
await loginAsync({ uid: uid }, { keepSessionInfo: true });
await authenticationController.onSuccessfulLogin(req, uid);
};
@ -459,6 +459,7 @@ authenticationController.localLogin = async function (req, username, password, n
};
const destroyAsync = util.promisify((req, callback) => req.session.destroy(callback));
const logoutAsync = util.promisify((req, callback) => req.logout(callback));
authenticationController.logout = async function (req, res, next) {
if (!req.loggedIn || !req.sessionID) {
@ -470,7 +471,7 @@ authenticationController.logout = async function (req, res, next) {
try {
await user.auth.revokeSession(sessionID, uid);
req.logout();
await logoutAsync();
await destroyAsync(req);
res.clearCookie(nconf.get('sessionKey'), meta.configs.cookie.get());

@ -41,8 +41,10 @@ middleware.buildHeader = helpers.try(async (req, res, next) => {
]);
if (!canLoginIfBanned && req.loggedIn) {
req.logout();
return res.redirect('/');
req.logout(() => {
res.redirect('/');
});
return;
}
res.locals.config = config;

@ -35,7 +35,7 @@ module.exports = function (middleware) {
async function authenticate(req, res) {
async function finishLogin(req, user) {
const loginAsync = util.promisify(req.login).bind(req);
await loginAsync(user);
await loginAsync(user, { keepSessionInfo: true });
await controllers.authentication.onSuccessfulLogin(req, user.uid);
req.uid = user.uid;
req.loggedIn = req.uid > 0;

@ -139,7 +139,7 @@ Auth.reloadRoutes = async function (params) {
})(req, res, next);
}, Auth.middleware.validateAuth, (req, res, next) => {
async.waterfall([
async.apply(req.login.bind(req), res.locals.user),
async.apply(req.login.bind(req), res.locals.user, { keepSessionInfo: true }),
async.apply(controllers.authentication.onSuccessfulLogin, req, req.uid),
], (err) => {
if (err) {

Loading…
Cancel
Save