Auth Guard

Auth Guards enable good UX by allowing or disallowing accidental navigation to a feature module or component before it is loaded and any data requests are made to the server.

For example, when a Manager logs in, they're automatically routed to the /manager/home path. The browser will cache this URL, and it will be completely plausible for a clerk to accidentally navigate to the same URL. Angular doesn't know whether a particular route is accessible to a user or not and, without an AuthGuard, it will happily render the Manager's home page and trigger server requests that will end up failing.

Regardless of the robustness of your frontend implementation, every REST API you implement should be properly secured server-side.
Let's update ...

Get Building Large-Scale Web Applications with Angular now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.