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

fix error when calling signout method with revoketokens set to true #226

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/auth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,20 @@ export class AuthService implements IAuthService {
}

protected async performEndSessionRequest(state?: string): Promise<void> {
if (this._tokenSubject.value != undefined) {
let requestJson: EndSessionRequestJson = {
postLogoutRedirectURI: this.authConfig.end_session_redirect_url,
idTokenHint: this._tokenSubject.value.idToken || '',
state: state || undefined,
};

let request: EndSessionRequest = new EndSessionRequest(requestJson);
let returnedUrl: string | undefined = await this.endSessionHandler.performEndSessionRequest(await this.configuration, request);

//callback may come from showWindow or via another method
if (returnedUrl != undefined) {
this.endSessionCallback();
}
} else {
//if user has no token they should not be logged in in the first place

let requestJson: EndSessionRequestJson = {
postLogoutRedirectURI: this.authConfig.end_session_redirect_url,
idTokenHint: this._tokenSubject.value ? this._tokenSubject.value.idToken || '' : '',
state: state || undefined,
};
let request: EndSessionRequest = new EndSessionRequest(requestJson);
let returnedUrl: string | undefined = await this.endSessionHandler.performEndSessionRequest(await this.configuration, request);

//callback may come from showWindow or via another method
if (returnedUrl != undefined) {
this.endSessionCallback();
}

}

protected async performAuthorizationRequest(authExtras?: StringMap, state?: string): Promise<void> {
Expand Down Expand Up @@ -354,11 +350,15 @@ export class AuthService implements IAuthService {
}

public async signOut(state?: string, revokeTokens?: boolean) {

if (revokeTokens) {
await this.revokeTokens();
}
const token = await this.storage.getItem(TOKEN_RESPONSE_KEY);

await this.storage.removeItem(TOKEN_RESPONSE_KEY);
if (token) {
await this.storage.removeItem(TOKEN_RESPONSE_KEY);
}

if ((await this.configuration).endSessionEndpoint) {
await this.performEndSessionRequest(state).catch((response) => {
Expand Down