caspian154 / beer-shelf

3 stars 1 forks source link

Angular: how to check if the current user is authenticated #4

Open caspian154 opened 7 years ago

caspian154 commented 7 years ago

In the user-list.component.js, I do the following, is there a way to inject this in any page that I don't want to be accessible when no user is logged in?

    this.currentUser = Auth.getCurrentUser();
    if (!this.currentUser) {
      $window.location.href = '#!/logout';
    }
MichaelWashburnJr commented 7 years ago

You could extract it out into your auth service. It might seem weird because it's manipulating your UI, but I don't know if theres a better place for shared controller code