Angular-auth-oidc-client: After successful login, getIsAuthorized still returns false for a bit.

Created on 4 Jan 2020  路  2Comments  路  Source: damienbod/angular-auth-oidc-client

If I perform a call to getIsAuthorized() immediately after a successul login, it will return false.
Sleeping for a second solves the problem, but this is only a workaround.

I think, call to getIsAuthorized() and authorize() have to be synced somehow.

Release 11 bug

Most helpful comment

If you are using a call to load_using_stsServer in your app initialization, then you might be experiencing the same issue as I did. The return type of load_using_stsServer is void, but it actually returns a promise that resolves with configuration retrieved from sts server. See, https://github.com/damienbod/angular-auth-oidc-client/blob/2044c48ddbecb447cb8339e34c649181169c926c/projects/angular-auth-oidc-client/src/lib/services/oidc.security.config.service.ts#L38

This creates a race condition, because we cannot wait for that call to finish before moving onto initializing the angular app. I worked around this issue in my app by casting the oidcConfigService to any and casting the oidcConfigService.load_using_stsServer to Promise<any>. Angular awaits any promises returned in the app initializers.

All 2 comments

If you are using a call to load_using_stsServer in your app initialization, then you might be experiencing the same issue as I did. The return type of load_using_stsServer is void, but it actually returns a promise that resolves with configuration retrieved from sts server. See, https://github.com/damienbod/angular-auth-oidc-client/blob/2044c48ddbecb447cb8339e34c649181169c926c/projects/angular-auth-oidc-client/src/lib/services/oidc.security.config.service.ts#L38

This creates a race condition, because we cannot wait for that call to finish before moving onto initializing the angular app. I worked around this issue in my app by casting the oidcConfigService to any and casting the oidcConfigService.load_using_stsServer to Promise<any>. Angular awaits any promises returned in the app initializers.

fixed in version 11, thanks for reporting

Was this page helpful?
0 / 5 - 0 ratings