Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: type issue LoginResponse #1780

Closed
yelhouti opened this issue Jun 17, 2023 · 1 comment · Fixed by #1781
Closed

[Bug]: type issue LoginResponse #1780

yelhouti opened this issue Jun 17, 2023 · 1 comment · Fixed by #1781

Comments

@yelhouti
Copy link
Contributor

Version

15.0.5

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Cannot destructure property 'isAuthenticated' of 'object null' as it is null.

Steps to reproduce the behavior

this.oidcSecurityService.checkAuthIncludingServer().subscribe(({ isAuthenticated }) => {}))


### A clear and concise description of what you expected to happen.

```true
checkAuthIncludingServer should always return a `LoginResponse`

Additional context

checkAuthIncludingServer(
configuration: OpenIdConfiguration,
allConfigs: OpenIdConfiguration[]
): Observable<LoginResponse> {
return this.checkAuthWithConfig(configuration, allConfigs).pipe(
switchMap((loginResponse) => {
const { isAuthenticated } = loginResponse;
if (isAuthenticated) {
return of(loginResponse);
}
return this.refreshSessionService
.forceRefreshSession(configuration, allConfigs)
.pipe(
tap((loginResponseAfterRefreshSession) => {
if (loginResponseAfterRefreshSession?.isAuthenticated) {
this.startCheckSessionAndValidation(configuration, allConfigs);
}
})
);
})
);
}

loginResponseAfterRefreshSession as can be seen can be null as forceRefreshSession can return null.

Either change the type to take that into account. or make forceRefreshSession return a LoginResponse with authenticated = false

@yelhouti
Copy link
Contributor Author

You rock thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant