Skip to content

Commit

Permalink
Implemented: wrap the logout api call in try catch in logout action
Browse files Browse the repository at this point in the history
  • Loading branch information
sanskar345 committed Oct 9, 2023
1 parent 6f44fe3 commit 1e6416a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ const actions: ActionTree<UserState, RootState> = {
// Calling the logout api to flag the user as logged out, only when user is authorised
// if the user is already unauthorised then not calling the logout api as it returns 401 again that results in a loop, thus there is no need to call logout api if the user is unauthorised
if(!payload?.isUserUnauthorised) {
let resp = await logout();
let resp;

// wrapping the parsing logic in try catch as in some case the logout api makes redirection, and then we are unable to parse the resp and thus the logout process halts
try {
resp = await logout();

// Added logic to remove the `//` from the resp as in case of get request we are having the extra characters and in case of post we are having 403
resp = JSON.parse(resp.startsWith('//') ? resp.replace('//', '') : resp)
} catch(err) {
logger.error('Error parsing data', err)
}

if(resp.logoutAuthType == 'SAML2SSO') {
if(resp?.logoutAuthType == 'SAML2SSO') {
redirectionUrl = resp.logoutUrl
}
}
Expand Down

0 comments on commit 1e6416a

Please sign in to comment.