File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
55## Unreleased
66
7+ - [ #138 ] ( https://github.com/os2display/display-client/pull/138 )
8+ - Avoided setting ER105 in url when no token exists in local storage.
79- [ #137 ] ( https://github.com/os2display/display-client/pull/137 )
810 - Add `no-cache´ directive to nginx setup.
911
Original file line number Diff line number Diff line change @@ -53,6 +53,17 @@ class TokenService {
5353 getExpireState = ( ) => {
5454 const expire = appStorage . getTokenExpire ( ) ;
5555 const issueAt = appStorage . getTokenIssueAt ( ) ;
56+ const token = appStorage . getToken ( ) ;
57+
58+ if ( expire === null ) {
59+ return constants . NO_EXPIRE ;
60+ }
61+ if ( issueAt === null ) {
62+ return constants . NO_ISSUED_AT ;
63+ }
64+ if ( token === null ) {
65+ return constants . NO_TOKEN ;
66+ }
5667
5768 const timeDiff = expire - issueAt ;
5869 const nowSeconds = Math . floor ( new Date ( ) . getTime ( ) / 1000 ) ;
@@ -121,11 +132,11 @@ class TokenService {
121132 checkToken = ( ) => {
122133 const expiredState = this . getExpireState ( ) ;
123134
124- if ( expiredState === constants . TOKEN_EXPIRED ) {
135+ if ( [ constants . NO_EXPIRE , constants . NO_ISSUED_AT , constants . NO_TOKEN ] . includes ( expiredState ) ) {
136+ // Ignore. No token saved in storage.
137+ } else if ( expiredState === constants . TOKEN_EXPIRED ) {
125138 statusService . setError ( constants . ERROR_TOKEN_EXPIRED ) ;
126- } else if (
127- expiredState === constants . TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED
128- ) {
139+ } else if ( expiredState === constants . TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED ) {
129140 statusService . setError (
130141 constants . ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED
131142 ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ const constants = {
1414 ERROR_RELEASE_FILE_NOT_LOADED : 'ER104' , // Release file could not be loaded.
1515 ERROR_TOKEN_EXPIRED : 'ER105' , // Token is expired.
1616 ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED : 'ER106' , // Token is valid but should have been refreshed.
17+ NO_TOKEN : 'NO_TOKEN' ,
18+ NO_EXPIRE : 'NO_EXPIRE' ,
19+ NO_ISSUED_AT : 'NO_ISSUED_AT' ,
1720} ;
1821
1922export default constants ;
You can’t perform that action at this time.
0 commit comments