Auth Guards
Our application can now render the SecureComponent or the LoginPanelComponent, depending on the URL that is provided by the browser. Currently, if no URL is provided, the application will render the SecureComponent, which is the main screen for our site. But what if we need to make sure that the SecureComponent is only rendered if the user has already logged into the website. In other words, how do we protect users from accessing areas of our site if they have not logged in? Angular uses what are known as authentication guards, or Auth Guards, to accomplish this.
The basic premise of an Auth Guard is to allow our code to check whether a user has the correct authorization to access a particular route. This is done by creating a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access