Skip to content

AngularFireAuthGuard is inconsistent with AuthPipe and AuthPipeGenerator parameters #2136

@ghost

Description

Version info

Angular:
8.1.2
Firebase:
6.3.1
AngularFire:
5.2.1

How to reproduce these conditions

const onlyAllowSelf: AuthPipeGenerator = (next: ActivatedRouteSnapshot) => map((user: User) => !!user && next.params.userId === user.uid);

const routes: Routes = [
  { path: 'users/:id', component: UserComponent, ...canActivate(onlyAllowSelf)},
];

Debug output

ERROR Error: Uncaught (in promise): TypeError: source.lift is not a function
TypeError: source.lift is not a function
at mapOperation (map.js:7)
at pipe.js:13
at Array.reduce ()
at piped (pipe.js:13)
at Observable.pipe (Observable.js:85)
at AngularFireAuthGuard.canActivate (auth-guard.js:22)
at router.js:4518
at Observable._subscribe (defer.js:8)
at Observable._trySubscribe (Observable.js:42)
at Observable.subscribe (Observable.js:28)
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone-evergreen.js:858
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:34182)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
at invokeTask (zone-evergreen.js:1603)

I was able to track this problem to https://github.com/angular/angularfire2/blob/992b15882c157d19f7779233e1d5e3da79cf0f03/src/auth-guard/auth-guard.ts#L28

This line seems to differentiate between an AuthPipeGenerator and an AuthPipe inputs by whether or not it has a name property, but if there is a named AuthPipeGenerator, like in my case or in your own docs then it tries to treat it as an AuthPipe, and fails

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