Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrienne / Clear logout state #897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 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 @@ -120,7 +127,7 @@
};

export const requestSingleSignOn = async () => {
const _requestSingleSignOn = async () => {

Check warning on line 130 in src/javascript/_common/auth.js

View workflow job for this annotation

GitHub Actions / Build and Test

Unexpected dangling '_' in '_requestSingleSignOn'

Check warning on line 130 in src/javascript/_common/auth.js

View workflow job for this annotation

GitHub Actions / Build and Test

Unexpected dangling '_' in '_requestSingleSignOn'

Check warning on line 130 in src/javascript/_common/auth.js

View workflow job for this annotation

GitHub Actions / build_and_deploy_preview_link

Unexpected dangling '_' in '_requestSingleSignOn'

Check warning on line 130 in src/javascript/_common/auth.js

View workflow job for this annotation

GitHub Actions / build_and_deploy_preview_link

Unexpected dangling '_' in '_requestSingleSignOn'

Check warning on line 130 in src/javascript/_common/auth.js

View workflow job for this annotation

GitHub Actions / build_and_deploy_preview_link

Unexpected dangling '_' in '_requestSingleSignOn'
// if we have previously logged in,
// this cookie will be set by the Callback page (which is exported from @deriv-com/auth-client library) to true when we have successfully logged in from other apps
const isLoggedInCookie = Cookies.get('logged_state') === 'true';
Expand All @@ -136,8 +143,9 @@
// 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
Loading