# Hiding Content if not authenticated

**URL:** <https://community.auth0.com/t/hiding-content-if-not-authenticated/78666>\
**Category:** Get Help\
**Created:** [February 21, 2022, 6:17pm UTC](https://community.auth0.com/t/hiding-content-if-not-authenticated/78666 "2022-02-21T18:17:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejazpacheco](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ejazpacheco](https://community.auth0.com/u/ejazpacheco)\
**Post date:** [February 21, 2022, 6:17pm UTC](https://community.auth0.com/t/hiding-content-if-not-authenticated/78666/1 "2022-02-21T18:17:57Z")

</div>

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?

```auto
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.

---

<div class="post-metadata">

**Author:** ![ejazpacheco](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ejazpacheco](https://community.auth0.com/u/ejazpacheco)\
**Post date:** [February 21, 2022, 6:27pm UTC](https://community.auth0.com/t/hiding-content-if-not-authenticated/78666/2 "2022-02-21T18:27:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 22, 2022, 11:16am UTC](https://community.auth0.com/t/hiding-content-if-not-authenticated/78666/3 "2022-02-22T11:16:43Z")

</div>

Thanks for sharing with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 22, 2022, 2:43pm UTC](https://community.auth0.com/t/hiding-content-if-not-authenticated/78666/4 "2022-02-22T14:43:16Z")

</div>


