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
Login stalls in some browsers. Page reload is required. #506
Comments
Hi @OysteinAmundsen - thanks for your report if If it's still happening, can you share a link to your app so we can take a look? |
This is the app: https://logic.noova.no/ |
Hi, yes - that is odd behaviour. When I look at the page redirect to the login form, I see that several iframes to the I managed to get a screenshot of 2 being created: This suggests to me that Can you check if you're creating multiple instances of the client, or somehow calling |
I just noticed also that you're loading 2 https://logic.noova.no/main-es5.39b377190bcb2ec90b2b.js They look like they do the same thing, just transpiled differently. This may explain the 2 iframe calls? |
I am having the same issue with an application that has been working on several months, this problem only started happening in the last 3 weeks. |
I think I fixed it by defering the use of isLoggedIn$ = new BehaviorSubject(false); // NEW
isAuthenticated$: Observable<boolean> = this.auth0Client$.pipe(
concatMap((client: Auth0Client) => from(client.isAuthenticated())),
tap((res: boolean) => {
this.loggedIn = res;
this.isLoggedIn$.next(this.loggedIn); // NEW
})
);
localAuthSetup() {
const checkAuth$ = this.isAuthenticated$.pipe(
concatMap((loggedIn: boolean) => {
if (loggedIn) {
return this.getUser$();
}
return of(loggedIn);
})
);
checkAuth$.subscribe((response: { [key: string]: any } | boolean) => {
this.loggedIn = !!response; // NEW
this.isLoggedIn$.next(this.loggedIn); // NEW
})
}
getTokenSilently$(options?): Observable<string> {
// Do not ask for token if we are not logged in yet.
return this.isLoggedIn$.pipe(
// Only truthy values will suffice
filter(isLoggedIn => !!isLoggedIn),
// Now we are logged in, and can continue to fetch the token.
switchMap(loggedIn =>
this.auth0Client$.pipe(concatMap((client: Auth0Client) => from(client.getTokenSilently(options))))
)
);
} Every line annotated with What I'm doing here, is providing my own observable for whether or not I'm logged in, and I'm using that observable to defer all calls to If this is the correct fix, your angular guide might need an update. If you have a better suggestion, I'm open. I'll leave it to you guys to decide if you want to close this issue or not, in case you decide that this is a regression in the product (seeing as other people are just experiencing this problem as well), :-) |
@OysteinAmundsen We do have this open issue on the Angular sample that I think are running into the same thing. I think this is down to how the sample is configured rather than a regression in the SDK itself. We are planning to upgrade the sample in the future, so this is useful feedback - thanks |
Closing for now but have recorded feedback internally regarding the Angular sample. |
Describe the problem
I've been following the universal login trail for angular from your docs and I've noticed something strange; when my application requires a login, it will kick off the auth0-spa-js.
loginWithRedirect
method, but the login page displays a blank page in some browsers. My users need to reload the url before the login page is displayed.The image below is all my users see before they F5:
No error in console and the same number of network requests done both before and after refresh.
I've tested the same in Firefox, Opera and Edge and it works fine, but in chrome, chrome incognito and Safari it stalls.
This occurred after implementing refresh-tokens to get login to work on Safari (ref. https://community.auth0.com/t/call-to-authorize-fails-on-safari/43477/8)
What was the expected behavior?
I would expect the same result as in other browsers; that the login dialog loads without the need for a manual page refresh.
Reproduction
I've followed the universal login trail for angular, and this is my config:
The rest of the service is as described under https://auth0.com/docs/quickstart/spa/angular2/01-login#add-the-authentication-service
I have a route guard which kicks off the login process:
Environment
I'm using
@auth0/auth0-spa-js: 1.9.0
@angular/core: 9.1.11
Tested in:
The text was updated successfully, but these errors were encountered: