Skip to content

Commit

Permalink
Merge pull request #897 from adrienne-deriv/clear-logout-state
Browse files Browse the repository at this point in the history
Adrienne / Clear logout state
  • Loading branch information
ahmadtaimoor-deriv authored Dec 31, 2024
2 parents 62e802d + 31ad242 commit bd87c00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@binary-com/binary-style": "^0.2.26",
"@binary-com/webtrader-charts": "^0.6.2",
"@deriv-com/analytics": "^1.26.1",
"@deriv-com/auth-client": "1.3.3",
"@deriv-com/auth-client": "1.3.8",
"@deriv-com/quill-ui": "^1.16.2",
"@deriv-com/utils": "^0.0.38",
"@deriv/deriv-api": "^1.0.15",
Expand Down
12 changes: 10 additions & 2 deletions src/javascript/_common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Cookies = require('js-cookie');
const requestOidcAuthentication = require('@deriv-com/auth-client').requestOidcAuthentication;
const OAuth2Logout = require('@deriv-com/auth-client').OAuth2Logout;
const Analytics = require('./analytics');
const Language = require('./language');

export const DEFAULT_OAUTH_LOGOUT_URL = 'https://oauth.deriv.com/oauth2/sessions/logout';

Expand Down Expand Up @@ -79,7 +80,13 @@ export const isOAuth2Enabled = () => {
};

export const requestOauth2Logout = onWSLogoutAndRedirect => {
OAuth2Logout(onWSLogoutAndRedirect);
const currentLanguage = Language.get();

OAuth2Logout({
WSLogoutAndRedirect : onWSLogoutAndRedirect,
redirectCallbackUri : `${window.location.origin}/${currentLanguage}/callback`,
postLogoutRedirectUri: `${window.location.origin}/${currentLanguage}/trading`,
});
};

export const requestSingleLogout = async (onWSLogoutAndRedirect) => {
Expand Down Expand Up @@ -136,8 +143,9 @@ export const requestSingleSignOn = async () => {
// if client.accounts in localStorage is empty - !isClientAccountsPopulated
// and if feature flag for OIDC Phase 2 is enabled - isAuthEnabled
if (isLoggedInCookie && !isCallbackPage && !isEndpointPage && !isClientAccountsPopulated && isAuthEnabled) {
const currentLanguage = Language.get();
await requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/en/callback`,
redirectCallbackUri: `${window.location.origin}/${currentLanguage}/callback`,
});
}
};
Expand Down

0 comments on commit bd87c00

Please sign in to comment.