fix: #9450 express session saved even if saveUninitialized explicitly passed in

v1.18.x
Julian Lam 4 years ago
parent 7754c1f66e
commit 9c52fd2e74

@ -11,6 +11,7 @@ const privileges = require('../privileges');
const plugins = require('../plugins');
const helpers = require('./helpers');
const auth = require('../routes/authentication');
const writeRouter = require('../routes/write');
const controllers = {
helpers: require('../controllers/helpers'),
@ -19,11 +20,12 @@ const controllers = {
const passportAuthenticateAsync = function (req, res) {
return new Promise((resolve, reject) => {
passport.authenticate('core.api', { session: false }, (err, user) => {
passport.authenticate('core.api', (err, user) => {
if (err) {
reject(err);
} else {
resolve(user);
res.on('finish', writeRouter.cleanup.bind(null, req));
}
})(req, res);
});

@ -63,3 +63,7 @@ Write.reload = async (params) => {
helpers.formatApiResponse(404, res);
});
};
Write.cleanup = (req) => {
req.session.destroy();
};

Loading…
Cancel
Save