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

Observable returned by AuthGuard does not wait until auth.loginWithRedirect finishes #659

Open
6 tasks done
Mobe91 opened this issue Nov 19, 2024 · 0 comments
Open
6 tasks done
Labels
bug This points to a verified bug in the code

Comments

@Mobe91
Copy link

Mobe91 commented Nov 19, 2024

Checklist

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

@Mobe91 Mobe91 added the bug This points to a verified bug in the code label Nov 19, 2024
Mobe91 added a commit to Mobe91/auth0-angular that referenced this issue Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

1 participant