Skip to content

Commit

Permalink
Explicitly tag PyDis messages for integrity
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Jul 3, 2024
1 parent 37f3b5c commit 7f8b0b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export async function getDiscordCode(scopes: OAuthScopes[], disableFunction?: (d
return;
}

if (message.data.pydis_source !== "oauth2_callback") {
// Ignore messages not from the callback
return;
}

if (message.isTrusted) {
windowRef?.close();

Expand Down
2 changes: 1 addition & 1 deletion src/pages/CallbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function CallbackPage(): JSX.Element {

if (!hasSent) {
setHasSent(true);
window.opener.postMessage({code: code, state: state});
window.opener.postMessage({code: code, state: state, pydis_source: "oauth2_callback"});
}

return <div/>;
Expand Down

0 comments on commit 7f8b0b0

Please sign in to comment.