title: Role-Based User Access Control With Firebase
body: <p>I try to create Role-Based User Access Control With Firebase to allow access to a route if the user is authenticated &amp;&amp; admin... and I´m trying it with this tutorial: <a href="https://angularfirebase.com/lessons/role-based-permissions-and-authorization-with-firebase-auth/" rel="nofollow noreferrer">https://angularfirebase.com/lessons/role-based-permissions-and-authorization-with-firebase-auth/</a>
  but i use angular 7 , 
  I get a syntax error on
   " Observable.of(null) " 
  and 
  ".subscribe(user => {
        this.user.next(user)" </p>
  
  <p>my My AuthService :</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { User } from 'src/app/register/user';
  import { AngularFireAuth } from '@angular/fire/auth';
  import { map } from "rxjs/operators";
  import { auth } from 'firebase';
  import { Router } from "@angular/router";
  import { AngularFirestore } from '@angular/fire/firestore';
  import { Observable } from 'rxjs';
  import { switchMap } from 'rxjs/operators';
  //import * as firebase from 'firebase/app';
  import { AngularFireDatabase } from '@angular/fire/database';
  import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
  import { observable } from 'rxjs/internal/symbol/observable';
  
  @Injectable({
    providedIn: 'root'
  })
  export class AuthService {
    user: BehaviorSubject&lt;User&gt; = new BehaviorSubject(null)
  
    constructor(public db: AngularFireDatabase, private fire: AngularFireAuth) {
  
      this.fire.authState.pipe(switchMap(auth =&gt; {
        if (auth) {
          /// signed in
          return this.db.object('users/${auth.uid}')
        } else {
          /// not signed in
          return Observable.of(null)
        }
      }).subscribe(user =&gt; {
        this.user.next(user)
      }))
  
  
    }
  </code></pre>
  
  <p>My User Model:</p>
  
  <pre><code>export interface Roles {
      reqUser: boolean;
      volunteer?: boolean;
      admin?:  boolean;
    }
  
    export class User {
      uid: string;
      email:    string;
      username: string;
      password : string;
      roles:    Roles;
      fullname : string;
  
      constructor(auth) {
        this.email    = auth.email
        this.uid = auth.uid
        this.roles    = { reqUser: true }
      }
    }
  </code></pre>