Skip to content

Commit

Permalink
chore: resolved pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienne-deriv committed Sep 30, 2024
1 parent 2601575 commit 1105aa0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 59 deletions.
11 changes: 9 additions & 2 deletions src/javascript/_common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const DEFAULT_OAUTH_LOGOUT_URL = 'https://oauth.deriv.com/oauth2/sessions

export const DEFAULT_OAUTH_ORIGIN_URL = 'https://oauth.deriv.com';

const LOGOUT_HANDLER_TIMEOUT = 10000;

const SocketURL = {
[URLConstants.derivP2pProduction]: 'blue.derivws.com',
[URLConstants.derivP2pStaging] : 'red.derivws.com',
Expand Down Expand Up @@ -85,7 +87,12 @@ export const getLogoutHandler = onWSLogoutAndRedirect => {
const allowedOrigin = getOAuthOrigin();
if (allowedOrigin === event.origin) {
if (event.data === 'logout_complete') {
await onWSLogoutAndRedirect();
try {
await onWSLogoutAndRedirect();
} catch (err) {
// eslint-disable-next-line no-console
console.error(`logout was completed successfully on oauth hydra server, but logout handler returned error: ${err}`);
}
}
}
};
Expand All @@ -107,7 +114,7 @@ export const getLogoutHandler = onWSLogoutAndRedirect => {

setTimeout(() => {
onWSLogoutAndRedirect();
}, 10000);
}, LOGOUT_HANDLER_TIMEOUT);
}

iframe.src = getOAuthLogoutUrl();
Expand Down
3 changes: 3 additions & 0 deletions src/javascript/app/base/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ const Header = (() => {
};

const logoutOnClick = async () => {
// This will wrap the logout call Client.sendLogoutRequest with our own logout iframe, which is to inform Hydra that the user is logging out
// and the session should be cleared on Hydra's side. Once this is done, it will call the passed-in logout handler Client.sendLogoutRequest.
// If Hydra authentication is not enabled, the logout handler Client.sendLogoutRequest will just be called instead.
const onLogoutWithOauth = await AuthClient.getLogoutHandler(Client.sendLogoutRequest);

onLogoutWithOauth();
Expand Down
57 changes: 0 additions & 57 deletions src/javascript/app/hooks/growthbook.js

This file was deleted.

0 comments on commit 1105aa0

Please sign in to comment.