From 8440c051e0fea04f2bac78d0d80af3caa4515215 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Sun, 7 Mar 2021 18:35:49 +0300 Subject: Revert "Removes Unused OAuth Cleaning" This reverts commit 7e0d4a9f Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- src/api/auth.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/api/auth.ts') 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(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 -- cgit v1.2.3