From b857e27156c495ba4ad367df6143bf925ffbc2f1 Mon Sep 17 00:00:00 2001 From: Sebastien Flory Date: Fri, 20 Dec 2024 17:31:53 +0100 Subject: [PATCH] Fix exit handler when redirecting (#9589) --- front/pages/api/login.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/pages/api/login.ts b/front/pages/api/login.ts index fce5c8a18cf3..79010505b89b 100644 --- a/front/pages/api/login.ts +++ b/front/pages/api/login.ts @@ -358,11 +358,12 @@ 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( @@ -370,7 +371,7 @@ async function handler( ); } } - }); + } } const { inviteToken, wId } = req.query;