Skip to content

Commit

Permalink
fix(authentication-oauth): OAuth redirect lost sometimes due to sessi…
Browse files Browse the repository at this point in the history
…on store race (feathersjs#2514)
  • Loading branch information
mterrel committed Dec 23, 2021
1 parent 325e633 commit 11d9491
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/authentication-oauth/src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ export default (options: OauthSetupSettings) => {
req.session.redirect = redirect as string;
req.session.query = query;

res.redirect(`${path}/connect/${name}?${qs.stringify(query as any)}`);
const sendRedirect = () => res.redirect(`${path}/connect/${name}?${qs.stringify(query as any)}`);

if (typeof req.session.save === 'function') {
req.session.save((err: any) => {
if (err) {
res.status(500).send(`Error storing session: ${err}`);
} else {
sendRedirect();
}
});
} else {
sendRedirect();
}
});

authApp.get('/:name/callback', (req: any, res: any) => {
Expand Down

0 comments on commit 11d9491

Please sign in to comment.