Skip to content

Commit

Permalink
Merge pull request #416 from FAIMS/upgrade-passport
Browse files Browse the repository at this point in the history
Upgrade passport to 0.7.0
  • Loading branch information
stevecassidy authored May 20, 2024
2 parents 6910f99 + fee26d4 commit eb56b4b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
34 changes: 18 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"nodemailer": "^6.9.9",
"nyc": "^15.1.0",
"oauth": "0.10.0",
"passport": "0.5.3",
"passport": "^0.7.0",
"passport-google-oauth20": "2.0.0",
"passport-local": "^1.0.0",
"passport-oauth2": "1.7.0",
Expand All @@ -67,7 +67,7 @@
"@types/multer": "^1.4.7",
"@types/node": "20.11.19",
"@types/nodemailer": "^6.4.13",
"@types/passport": "1.0.7",
"@types/passport": "^1.0.16",
"@types/passport-google-oauth20": "2.0.13",
"@types/passport-local": "^1.0.35",
"@types/passport-oauth2": "1.4.15",
Expand Down
19 changes: 19 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ app.use(
maxAge: 24 * 60 * 60 * 1000 * 365, // BBS 20220831 changed to 1 year
})
);
// https://github.com/jaredhanson/passport/issues/904
// register regenerate & save after the cookieSession middleware initialization
// fix for bug in passport 0.7.0 and compatibility with cookie-session
app.use((request, response, next) => {
if (request.session && !request.session.regenerate) {
request.session.regenerate = cb => {
if (cb) cb('');
return request.session;
};
}
if (request.session && !request.session.save) {
request.session.save = cb => {
if (cb) cb('');
return request.session;
};
}
next();
});

app.use(express.urlencoded({extended: true}));
// allow large JSON objects to be posted
app.use(express.json({limit: '200mb'}));
Expand Down
1 change: 0 additions & 1 deletion src/couchdb/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,6 @@ export const streamNotebookFilesAsZip = async (
}
const stream = Stream.Readable.from(chunks);
const filename = generateFilename(file, key, hrid, fileNames);
console.log('adding to zip: ', filename);
fileNames.push(filename);
await archive.append(stream, {
name: filename,
Expand Down
8 changes: 6 additions & 2 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ app.get('/', async (req, res) => {
}
});

app.get('/logout/', (req, res) => {
app.get('/logout/', (req, res, next) => {
if (req.user) {
req.logout();
req.logout(err => {
if (err) {
return next(err);
}
});
}
res.redirect('/');
});
Expand Down

0 comments on commit eb56b4b

Please sign in to comment.