diff --git a/apps/login/src/components/login-otp.tsx b/apps/login/src/components/login-otp.tsx index c010c89d62..0b0f8c2f0c 100644 --- a/apps/login/src/components/login-otp.tsx +++ b/apps/login/src/components/login-otp.tsx @@ -84,7 +84,7 @@ export function LoginOTP({ value: host ? { urlTemplate: - `${host.includes("localhost") ? "http://" : "https://"}${host}/otp/method=${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}` + + `${host.includes("localhost") ? "http://" : "https://"}${host}/otp/${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}` + (authRequestId ? `&authRequestId=${authRequestId}` : ""), } : {}, @@ -182,11 +182,11 @@ export function LoginOTP({ function setCodeAndContinue(values: Inputs, organization?: string) { return submitCode(values, organization).then(async (response) => { - setLoading(true); - // Wait for 2 seconds to avoid eventual consistency issues with an OTP code being verified in the /login endpoint - await new Promise((resolve) => setTimeout(resolve, 2000)); + if (response && "sessionId" in response) { + setLoading(true); + // Wait for 2 seconds to avoid eventual consistency issues with an OTP code being verified in the /login endpoint + await new Promise((resolve) => setTimeout(resolve, 2000)); - if (response) { const url = authRequestId && response.sessionId ? await getNextUrl(