diff options
| author | 2021-03-07 18:35:49 +0300 | |
|---|---|---|
| committer | 2021-03-07 18:35:49 +0300 | |
| commit | 8440c051e0fea04f2bac78d0d80af3caa4515215 (patch) | |
| tree | 05f6cb500b16cc69a0759a6f419ec4bb72df3d55 /src/api | |
| parent | Merge pull request #141 from python-discord/discord-oauth (diff) | |
Revert "Removes Unused OAuth Cleaning"
This reverts commit 7e0d4a9f
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to '')
| -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 | 
