diff options
-rw-r--r-- | src/api/auth.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/auth.ts b/src/api/auth.ts index 160c832..50f9a69 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -110,6 +110,13 @@ export async function getDiscordCode(scopes: OAuthScopes[]): Promise<{code: stri "height=700,width=500,location=no,menubar=no,resizable=no,status=no,titlebar=no,left=300,top=300" ); + // Clean up on login + const interval = setInterval(() => { + if (windowRef?.closed) { + clearInterval(interval); + } + }, 500); + // Handle response const code = await new Promise<string>(resolve => { window.onmessage = (message: MessageEvent) => { @@ -121,6 +128,8 @@ export async function getDiscordCode(scopes: OAuthScopes[]): Promise<{code: stri if (message.isTrusted) { windowRef?.close(); + clearInterval(interval); + // State integrity check if (message.data.state !== state.toString()) { // This indicates a lack of integrity |