@@ -22,8 +22,6 @@ const useSilentLoginAndLogout = ({
22
22
isOAuth2Enabled : boolean ;
23
23
oAuthLogout : ( ) => Promise < void > ;
24
24
} ) => {
25
- const loggedState = Cookies . get ( 'logged_state' ) ;
26
-
27
25
const clientAccounts = JSON . parse ( localStorage . getItem ( 'client.accounts' ) || '{}' ) ;
28
26
const isClientAccountsPopulated = Object . keys ( clientAccounts ) . length > 0 ;
29
27
const isSilentLoginExcluded =
@@ -32,37 +30,38 @@ const useSilentLoginAndLogout = ({
32
30
window . location . pathname . includes ( 'endpoint' ) ;
33
31
34
32
useEffect ( ( ) => {
35
- window . addEventListener (
36
- 'message' ,
37
- message => {
38
- if ( message . data ?. event === 'login_required' ) {
39
- console . log ( 'OIDC: prompt none says we are logged out' ) ;
40
- if ( isClientAccountsPopulated ) {
41
- oAuthLogout ( ) ;
42
- }
43
- } else if ( message . data ?. event === 'sso_required' ) {
44
- console . log ( 'OIDC: we need to SSO NOW' ) ;
45
- // requestOidcAuthentication({
46
- // redirectCallbackUri: `${window.location.origin}/callback`,
47
- // });
48
- }
49
- } ,
50
- false
51
- ) ;
52
33
// NOTE: Remove this logic once social signup is intergated with OIDC
53
34
const params = new URLSearchParams ( window . location . search ) ;
54
35
const isUsingLegacyFlow = params . has ( 'token1' ) && params . has ( 'acct1' ) ;
55
- if ( isUsingLegacyFlow && loggedState === 'false' && isOAuth2Enabled ) {
36
+ if ( isUsingLegacyFlow && isOAuth2Enabled ) {
56
37
return ;
57
38
}
58
39
59
40
if ( isOAuth2Enabled && ! isUsingLegacyFlow && ! isClientAccountsPopulated && ! isSilentLoginExcluded ) {
41
+ window . addEventListener (
42
+ 'message' ,
43
+ message => {
44
+ if ( message . data ?. event === 'login_required' ) {
45
+ console . log ( 'OIDC: prompt none says we are logged out' ) ;
46
+ if ( isClientAccountsPopulated ) {
47
+ oAuthLogout ( ) ;
48
+ }
49
+ } else if ( message . data ?. event === 'sso_required' || message . data ?. event === 'login_successful' ) {
50
+ console . log ( 'OIDC: we need to SSO NOW' , message . data ?. event ) ;
51
+ // requestOidcAuthentication({
52
+ // redirectCallbackUri: `${window.location.origin}/callback`,
53
+ // });
54
+ }
55
+ } ,
56
+ false
57
+ ) ;
58
+
60
59
console . log ( 'OIDC: checking if we need SSO...' ) ;
61
60
const userManager = new UserManager ( {
62
61
authority : 'https://qa20.deriv.dev' ,
63
62
client_id : '1000005' ,
64
- redirect_uri : 'https://localhost:8443 /callback' ,
65
- silent_redirect_uri : 'https://localhost:8443 /silent-callback' ,
63
+ redirect_uri : 'https://qa110.deriv.dev /callback' ,
64
+ silent_redirect_uri : 'https://qa110.deriv.dev /silent-callback' ,
66
65
response_type : 'code' ,
67
66
scope : 'openid' ,
68
67
stateStore : new WebStorageStateStore ( { store : window . localStorage } ) ,
0 commit comments