Skip to content

Commit

Permalink
Merge pull request #49 from thisyahlen-deriv/thisyahlen/remove-host-o…
Browse files Browse the repository at this point in the history
…rigin-check

Thisyahlen/remove host origin check
  • Loading branch information
thisyahlen-deriv authored Sep 27, 2024
2 parents 6f51f20 + ab84780 commit 87da2f1
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/hooks/useOAuth2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useCallback } from 'react';
import { getOAuthLogoutUrl, getOAuthOrigin } from '../constants/';
import { getOAuthLogoutUrl } from '../constants/';
import { useIsOAuth2Enabled } from './useIsOAuth2Enabled';

type MessageEvent = {
Expand Down Expand Up @@ -31,18 +31,10 @@ export const useOAuth2 = (OAuth2GrowthBookConfig: OAuth2GBConfig, WSLogoutAndRed
if (!isOAuth2Enabled) return;

const onMessage = async (event: MessageEvent) => {
const allowedOrigin = getOAuthOrigin();
console.log('allowedOrigin', allowedOrigin);
console.log('event.origin', event);
if (allowedOrigin === event.origin) {
if (event.data === 'logout_complete') {
console.warn('logout completed');
WSLogoutAndRedirect();
} else {
console.warn('Unexpected message received: ', event.data);
}
if (event.data === 'logout_complete') {
WSLogoutAndRedirect();
} else {
console.warn('Unexpected postmessage origin: ', event.origin);
console.warn('Unexpected message received: Logout failed ', event.data);
}
};

Expand Down

0 comments on commit 87da2f1

Please sign in to comment.