Skip to content

Commit

Permalink
Merge pull request #132 from os2display/feature/2478-refresh-token
Browse files Browse the repository at this point in the history
Removed token errors when logging in again
  • Loading branch information
tuj authored Sep 20, 2024
2 parents 56d9bf9 + 48bbd80 commit b6f8ecf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/error-codes.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/service/token-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class TokenService {
);
} else {
const err = statusService.error;

if (
err !== null &&
[
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b6f8ecf

Please sign in to comment.