Auth guard - angular - toastr service is not working

176 views Asked by At
export class AuthGuard implements CanActivate {
  constructor(private accountService:AccountService, private toastr:ToastrService){}
  canActivate(): Observable<boolean> {
    return this.accountService.currentUser$.pipe(
      map(user => {
        if (user) return true;
        this.toastr.error('You shall not pass!'); <====== this is not working
        return false;
      })
    )
  }  
}

I have a problem that toastr service error is not displayed as expected as an unauthorized .. Has anyone faced the same problem and fixed it ?

0

There are 0 answers