You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I make a custom guard, that works like the auto-login guard, except for the auto-login part. Instead I want to redirect the users to the app's internal login page. This is because we offer multiple different identity providers that the user can choose from.
I tried this documentation example but that doesn't work. I checked the library code, and oidcSecurityService.isAuthenticated$ is backed by private readonly authenticatedInternal$ = new BehaviorSubject<AuthenticatedResult>(DEFAULT_AUTHRESULT); from auth-state.service.ts. Where DEFAULT_AUTHRESULT.isAuthenticated is false.
The documentation for the property states:
Emits each time an authorization event occurs.
But that is clearly not true, as it always initially emits false.
Now you can see my problem. Once I get redirected back to my app, oidcSecurityService.isAuthenticated$.pipe(take(1)) always emits false exactly once, and therefore the route guard immediately concludes that you are not authenticated. That the AppComponent is still running checkAuth in the background, and will soon update the authentication state to say that you are authenticated is of no consequence.
Would it be possible to either:
Export more of the internals of the library? So that I can implement my own alternative to AutoLoginPartialRoutesGuard. Currently that's not possible, because the AutoLoginService, AuthStateService, and LoginService are not exported as part of this library's public API.
I can probably workaround the route guard issue by putting a delay in my CallbackComponent before it routes. However, I really like that the AutoLoginPartialRoutesGuard saves the target route and redirects back to the target route if you're logged in. In my opinion that is not related to automatic login at all. And I really want that feature. But to make that I would have to rewrite a lot of library internals simply because they're inaccessible.
The text was updated successfully, but these errors were encountered:
What Version of the library are you using?
18.0.0
Question
How can I make a custom guard, that works like the auto-login guard, except for the auto-login part. Instead I want to redirect the users to the app's internal login page. This is because we offer multiple different identity providers that the user can choose from.
I tried this documentation example but that doesn't work. I checked the library code, and
oidcSecurityService.isAuthenticated$
is backed byprivate readonly authenticatedInternal$ = new BehaviorSubject<AuthenticatedResult>(DEFAULT_AUTHRESULT);
fromauth-state.service.ts
. WhereDEFAULT_AUTHRESULT.isAuthenticated
isfalse
.The documentation for the property states:
But that is clearly not true, as it always initially emits
false
.Now you can see my problem. Once I get redirected back to my app,
oidcSecurityService.isAuthenticated$.pipe(take(1))
always emitsfalse
exactly once, and therefore the route guard immediately concludes that you are not authenticated. That theAppComponent
is still runningcheckAuth
in the background, and will soon update the authentication state to say that you are authenticated is of no consequence.Would it be possible to either:
AutoLoginPartialRoutesGuard
. Currently that's not possible, because theAutoLoginService
,AuthStateService
, andLoginService
are not exported as part of this library's public API.PartialRoutesGuard
that makes the part that performs auto-login configurable?I can probably workaround the route guard issue by putting a delay in my
CallbackComponent
before it routes. However, I really like that theAutoLoginPartialRoutesGuard
saves the target route and redirects back to the target route if you're logged in. In my opinion that is not related to automatic login at all. And I really want that feature. But to make that I would have to rewrite a lot of library internals simply because they're inaccessible.The text was updated successfully, but these errors were encountered: