Skip to content

Commit

Permalink
fix: only logout STFC users with a valid token
Browse files Browse the repository at this point in the history
Only call the logout method on the STFC web service if: there is a valid token in the cache, or the web service reports that the token is valid
  • Loading branch information
simonfernandes committed Jun 13, 2023
1 parent 973d3f2 commit 132f050
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/user-office-backend/src/auth/StfcUserAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ export class StfcUserAuthorization extends UserAuthorization {
if (token) {
this.uowsTokenCache.remove(token);

const isValidToken = await this.isExternalTokenValid(token);

if (!isValidToken) {
logger.logInfo(
'UOWS token found to be invalid, skipping UOWS logout call',
{ token }
);

return Promise.resolve('User already logged out');
}

return await client.logout(token).catch(() => {
logger.logWarn('Failed to log out user', { token });

Expand Down

0 comments on commit 132f050

Please sign in to comment.