From 0e43f92fef4c137df35c3bafcd013d06829c1d37 Mon Sep 17 00:00:00 2001 From: Michael Shihjay Chen Date: Tue, 24 Sep 2024 21:10:08 -0700 Subject: [PATCH] fix timer --- components/magicLink/login.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/magicLink/login.tsx b/components/magicLink/login.tsx index dd360546..5452ff67 100644 --- a/components/magicLink/login.tsx +++ b/components/magicLink/login.tsx @@ -67,17 +67,20 @@ export default function Login({ challenge, clinical=false, authonly=false, clien let check = false; let proceed = false; let timer = 0; - while (!check || timer < 50) { - await sleep(5); - const nonce_check = await fetch("/api/auth/check", - { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({nonce: nonce}) }) - .then((res) => res.json()); - if (nonce_check.success) { + while (!check) { + if (timer < 200) { + await sleep(5); + const nonce_check = await fetch("/api/auth/check", + { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({nonce: nonce}) }) + .then((res) => res.json()); + if (nonce_check.success) { + check = true; + proceed = true; + } + timer++; + } else { check = true; - proceed = true; } - timer++; - console.log(timer) } if (proceed) { await fetch("/api/magicLink/login",