-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code
Description
Checklist
- The issue can be reproduced in the auth0-angular sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
The current implementation of the AuthGuard returns an Observable from canActivate that is produced like this:
private redirectIfUnauthenticated(
state: RouterStateSnapshot
): Observable<boolean> {
return this.auth.isAuthenticated$.pipe(
tap((loggedIn) => {
if (!loggedIn) {
this.auth.loginWithRedirect({
appState: { target: state.url },
});
}
})
);
}The logic of this is that auth.loginWithRedirect will perform a redirect for login when the user is not logged in. However, auth.loginWithRedirect also returns an Observable which is ignored by this implementation. This means that the consumer of the guard will not wait for auth.loginWithRedirect to complete.
Reproduction
I did not try to reproduce effects of this issue.
Additional context
No response
auth0-angular version
2.2.3
Angular version
13
Which browsers have you tested in?
Chrome
iSeremet-Reloadly and mhkolk
Metadata
Metadata
Assignees
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code