From 5cb84927ea0718c1295ddc739ea880175caee1df Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 28 Oct 2022 18:10:10 -0400 Subject: [PATCH] 400s only log out on invalid grant error (#3924) --- libs/common/src/services/api.service.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libs/common/src/services/api.service.ts b/libs/common/src/services/api.service.ts index 7c39958bce..6c15d85c0d 100644 --- a/libs/common/src/services/api.service.ts +++ b/libs/common/src/services/api.service.ts @@ -2360,16 +2360,6 @@ export class ApiService implements ApiServiceAbstraction { tokenError: boolean, authed: boolean ): Promise { - if ( - authed && - ((tokenError && response.status === 400) || - response.status === 401 || - response.status === 403) - ) { - await this.logoutCallback(true); - return null; - } - let responseJson: any = null; if (this.isJsonResponse(response)) { responseJson = await response.json(); @@ -2377,6 +2367,20 @@ export class ApiService implements ApiServiceAbstraction { responseJson = { Message: await response.text() }; } + if (authed) { + if ( + response.status === 401 || + response.status === 403 || + (tokenError && + response.status === 400 && + responseJson != null && + responseJson.error === "invalid_grant") + ) { + await this.logoutCallback(true); + return null; + } + } + return new ErrorResponse(responseJson, response.status, tokenError); }