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

fix: fix the missing token #938

Merged
merged 1 commit into from
Feb 27, 2025
Merged
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
19 changes: 14 additions & 5 deletions src/javascript/_common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,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 @@ -144,12 +144,21 @@
// and if feature flag for OIDC Phase 2 is enabled - isAuthEnabled
// Check if any account or its linked account is missing a token

const hasMissingToken = Object.values(clientAccounts).some((account) => {
// Check if current account is missing token
if (!account?.token) {
return true; // No linked accounts and no token
}
return false;
});

const shouldRequestSignOn =
isLoggedInCookie &&
!isCallbackPage &&
!isEndpointPage &&
(!isClientAccountsPopulated) &&
isAuthEnabled;
isLoggedInCookie &&
!isCallbackPage &&
!isEndpointPage &&
(!isClientAccountsPopulated ||
(isClientAccountsPopulated && hasMissingToken)) &&
isAuthEnabled;

if (shouldRequestSignOn) {
const currentLanguage = Language.get();
Expand Down
Loading