Skip to content

canActivate is broken on 6.0.0 #2312

Closed
Closed
@jimmykane

Description

@jimmykane

Version info

Angular: 9-rc14

Firebase: 7.8.0

AngularFire: 6.0.0-rc0

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

Failing test unit, Plunkr, or JSFiddle demonstrating the problem

Steps to set up and reproduce

Sample data and security rules

<-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

canActivate works

Actual behavior

canActivate doesn't work

canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    if (this.authenticationService.authenticated()) {
      return true;
    }

    return this.authenticationService.user.pipe(take(1)).pipe(map(user => !!user)).pipe(tap(loggedIn => {
      if (!loggedIn) {
        this.logger.warn(`Access denied`);
        this.snackBar.open('Access denied', null, {
          duration: 2000,
        });
        this.router.navigate(['/login']);
      }
    }))

  }

The above used to work.

Currently with 6.0.0-rc0 the above doesn't work

Returning true or an observable does not allow the route to work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions