Skip to content

Commit

Permalink
fix timer
Browse files Browse the repository at this point in the history
  • Loading branch information
shihjay2 committed Sep 25, 2024
1 parent 1a888ea commit 0e43f92
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/magicLink/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0e43f92

Please sign in to comment.