Skip to content

Commit

Permalink
Fix exit handler when redirecting (#9589)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle authored Dec 20, 2024
1 parent ed262e5 commit b857e27
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions front/pages/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,20 @@ async function handler(
// Check if the user should be redirect to another region.
const regionLookupClient = new RegionLookupClient();
const r = await regionLookupClient.lookupUser(session.user);
r.forEach((result, region) => {
for (const [region, result] of r) {
if (result.reponse.user?.email) {
if (!result.isCurrentRegion) {
//TODO(multi-regions): keep the querystring when redirecting
res.redirect(`${result.regionUrl}/api/login`);
// Skip the rest of the handler
return;
} else {
console.log(
`User ${result.reponse.user.email} is already in the correct region ${region} (${result.regionUrl}).`
);
}
}
});
}
}

const { inviteToken, wId } = req.query;
Expand Down

0 comments on commit b857e27

Please sign in to comment.