auth0 / auth0-angular

Auth0 SDK for Angular Single Page Applications
MIT License
176 stars 58 forks source link

isAuthenticated first returns true and then false after successful login. #557

Closed chao-deng-ryan closed 8 months ago

chao-deng-ryan commented 9 months ago

Checklist

Description

I configured and used the AuthService according to the documentation. When the login is successful, isAuthenticated$ first returns true, and then returns false.(Reappears when logging in for the first time) Click login again, isAuthenticated$ returns true.

Reproduction

1.config.set({ domain: environment.auth0Domain, clientId: environment.auth0ClientId, audience: environment.auth0Audience, issuer: environment.auth0Issuer, redirectUri: ${document.location.origin}${document.location.search}, useRefreshTokens: true, cacheLocation: 'localstorage', httpInterceptor: { allowedList: [ { uri: ${environment.baseUrl}/*, allowAnonymous: true, }, ], }, }); 2.Open an incognito window in Firefox,in page: constructor(public auth: AuthService) {init()} 3.function init() { this.auth.isAuthenticated$.subscribe((isAuthenticated) => { console.log('auth.isAuthenticated$: ', isAuthenticated); this.isLogIn = isAuthenticated; }); } 4.first login, click login button, and input account information... 5.isAuthenticated$ first returns true, and then returns false. 6.Click login again, isAuthenticated$ returns true

Additional context

No response

auth0-angular version

1.7.0

Angular version

12.1.4

Which browsers have you tested in?

Chrome, Safari, Firefox

frederikprijck commented 9 months ago

Thanks for reaching out. I see you are using V1 of our SDK. Can you verify this behaves better in V2?

Additionally, are there any logs in auth0?

I also see you are using incognito. Does it behave differently without using incognito? Incognito can cause issues with third party cookies, which you can avoid by using custom domains.

Additionally, if you can not update to V2 of our SDK, please understand that we only support versions of angular that are supported by Google (V12 isn't). However, in that case, can you try setting useRefreshTokensFallback to false and see if the behavior persists?

frederikprijck commented 9 months ago

Having said the above, I am unable to reproduce this in Firefox using the latest version of our SDK. Can you try our sample ?

frederikprijck commented 8 months ago

Closing due to no response.