Hiding Content if not authenticated

Hi There,
I have an Angular application which is using Universal Login.
When i hit the URL for my site, i see the content of my site for a brief second, and then it redirects me to the login page. This isn’t ideal as it reveals some secure information.

I’ve attempted to wrap my entire app.component.html in an <ng-container *ngIf=“auth.isAuthenticated$”> tag.

This works, however. I’m running into another issue. I have a breakpoint subscriber that I use on page load in my app.component.ts , that is giving me an undefined as the ngAfterViewOnIt has already been executed pre-login. Has anyone ran into a similar scenario and had a solution?

ngAfterViewInit(): void {
    this.observer
    .observe(['(max-width: 800px)'])
    .pipe(delay(1))
    .subscribe((res) => {
          if (res.matches) {
             this.sidenav.mode = 'over';

Getting a cannot set property of undefined.

Okay, i think i found a solution. Remove my function from ngAfterViewInit, and create a new function. From there, only if auth.isAuthenticated returns true then trigger than function.

Placed that logic in my ngOnit.

1 Like

Thanks for sharing with the rest of community!