Security in Angular

Security in Angular: Login and Register in Angular, Route Guards and HTTP Interceptors.

Updated

  1. Login and Register in Angular (Journeyman): An Auth service sends the credentials to the API, keeps the signed-in user in a signal and the token in localStorage, and signs out by forgetting both. Sign-in and register pages show the API's errors, and the header shows who's signed in. Hiding buttons is for convenience; the API is what keeps data safe.
  2. Route Guards and HTTP Interceptors (Freelancer): A route guard decides whether a page may open, and sends visitors who aren't signed in to the sign-in page and back again afterwards. An HTTP interceptor sees every request, so one adds the token to every call to your API, and signs the user out when the API answers 401.