Redirect to login page if response status 401

Here is how I handle user authentication. If you follow this pattern, all you have to do is inject the authentication service in whatever service is doing HTTP requests, and call next(false) on its authentication notifier whenever a 401 is encountered. The subscription in the app component will handle all interaction with the navigation system.

1 Like