angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[question] suggested way to direct user through login flow when root / route is hit?

Open kemmis opened this issue 7 years ago • 2 comments

In the readme it says

The guard should not be active on the default route, where the authorization request is processed.

Since our site is completely protected, we want all unauthenticated users automatically sent over to the oidc site when they first loaded the main root path "/" of the angular site. Additionally, we want the "/" route redirect to "/module1/" when they are authenticated, but still keeping Module1 lazy-loading, thus Module1 should not be loaded in the first place if the user is not authenticated.

Are there any good examples that can do this? Currently our app is always loading Module1 and rendering a component prior to redirecting the user to the oidc site. Maybe I need to remove the redirect in our route config that currently forwards "/" -> "/module1/", and simply have something in the app.component.ts that can manage that to forward to /module1/ as the default?

kemmis avatar Aug 30 '19 10:08 kemmis

I would do what you said remove the router config to go straight to module1 and instead land on an empty component that triggers a check to see if you are logged (I have a service that subscribes to getIsAuthorized() in the constructor and sets a isAuthorized variable in the subscription) then on ngOnInit I check if the service.isAuthorized is true -> route to module1.... if not -> trigger login programmatically.

JoellyR avatar Oct 09 '19 19:10 JoellyR

This has been refactored and changed in version 11 which we plan to release in the next few days after testing

Greetings Damien

damienbod avatar Apr 30 '20 15:04 damienbod