diff --git a/pairent_frontend_react/src/API/User.js b/pairent_frontend_react/src/API/User.js index d48ee9b..1bed60c 100644 --- a/pairent_frontend_react/src/API/User.js +++ b/pairent_frontend_react/src/API/User.js @@ -22,7 +22,7 @@ class IAPIObject { static storage_key = undefined; static _checkStorageSupport() { - if (storage_key === undefined) { + if (this.storage_key === undefined) { throw Error('This doesn\'t support local storage'); } } @@ -40,14 +40,18 @@ class IAPIObject { /** @returns {ThisType} */ static restoreFromLocalStorage() { _checkStorageSupport(); - if (!window.localStorage.getItem(storage_key)) + if (!window.localStorage.getItem(this.storage_key)) return false; - return new APIToken(window.localStorage.getItem(storage_key)); + return new APIToken(window.localStorage.getItem(this.storage_key)); } /** @returns {boolean} */ static isCached() { - _checkStorageSupport(); + this._checkStorageSupport(); + if (window.localStorage.getItem(this.storage_key)) { + return true; + } + return false; } /**