AngularFire2 (4.0) authentication with CanActivate not working

Viewed 1849

I'm building an Angular 4 + FireBase (4.0.0.rc0) application based on the following tutorial: https://coursetro.com/posts/code/32/Create-a-Full-Angular-Authentication-System-with-Firebase

The tutorial is based on a older version of FireBase. I was able to convert almost everything to the latest version. I'm struggling with transforming this canActivate function. It throws on Observable.from(this.afAuth) the following error:

[ts]
Argument of type 'AngularFireAuth' is not assignable to parameter of type 'ArrayLike<{}>'.
Property 'length' is missing in type 'AngularFireAuth'.
(property) AuthGuard.afAuth: AngularFireAuth
export class AuthGuard implements CanActivate {

  constructor(private afAuth: AngularFireAuth, private router: Router) { }

  canActivate(): Observable<boolean> {
    return Observable.from(this.afAuth)
      .take(1)
      .map(state => !!state)
      .do(authenticated => {
        if
         (!authenticated) this.router.navigate(['/login']);
      })
  }
}

How can I make this work?

Thanks!

1 Answers
Related