diff --git a/src/routes/Intro/useAppleLogin.ts b/src/routes/Intro/useAppleLogin.ts index 7d5465838..e6a39cbb9 100644 --- a/src/routes/Intro/useAppleLogin.ts +++ b/src/routes/Intro/useAppleLogin.ts @@ -52,7 +52,17 @@ const useAppleLogin = (): [() => Promise, () => void] => { usePopup: true, }); + const timeoutId = setTimeout(() => { + if (started.current) { + started.current = false; + reject(new Error('Apple login popup was closed')); + } + }, 1000); + window.AppleID.auth.signIn().then((response: AppleSignInResponse) => { + clearTimeout(timeoutId); + started.current = false; + if (response.authorization) { try { const idToken = response.authorization.id_token; @@ -84,6 +94,10 @@ const useAppleLogin = (): [() => Promise, () => void] => { } else { reject(new Error('No authorization received from Apple')); } + }).catch((error) => { + clearTimeout(timeoutId); + started.current = false; + reject(error); }); }); }, []);