diff --git a/CHANGELOG.md b/CHANGELOG.md index 47456a58..1e4c12b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## Unreleased +- [#132](https://github.com/os2display/display-client/pull/132) + - Remove token errors after re-login. - [#131](https://github.com/os2display/display-client/pull/131) - Moved localstorage calls into helper class AppStorage. - Cleaned up project structure. diff --git a/docs/error-codes.md b/docs/error-codes.md index 07616ead..4a587d52 100644 --- a/docs/error-codes.md +++ b/docs/error-codes.md @@ -1,6 +1,6 @@ # Error codes -* ER101: API returns 401. Token could not be refreshed. +* ER101: API returns 401. Token could not be refreshed. This could be caused by logging out in the admin. * ER102: Token could not be refreshed in normal refresh token loop. * ER103: Token refresh aborted, refresh token, iat and/or exp not set. * ER104: Release file could not be loaded. diff --git a/src/service/token-service.js b/src/service/token-service.js index fbbea8ed..a411fed7 100644 --- a/src/service/token-service.js +++ b/src/service/token-service.js @@ -131,6 +131,7 @@ class TokenService { ); } else { const err = statusService.error; + if ( err !== null && [ @@ -165,6 +166,19 @@ class TokenService { appStorage.setScreenId(data.screenId); appStorage.setTenant(data.tenantKey, data.tenantId); + // Remove token expired error codes. + if ( + [ + constants.ERROR_TOKEN_REFRESH_FAILED, + constants.ERROR_TOKEN_REFRESH_LOOP_FAILED, + constants.ERROR_TOKEN_EXP_IAT_NOT_SET, + constants.ERROR_TOKEN_EXPIRED, + constants.ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED, + ].includes(statusService.error) + ) { + statusService.setError(null); + } + resolve({ status: constants.LOGIN_STATUS_READY, screenId: data.screenId,