Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exit handler when redirecting #9589

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading