obabichev / react-token-auth

84 stars 22 forks source link

After onUpdateToken tokens not updated in localStorage #3

Closed kubYkula closed 4 years ago

kubYkula commented 4 years ago
const checkExpiry = async () => {
    if (privateToken && isExpired(getExpire(privateToken))) {
        const newToken = onUpdateToken ? await onUpdateToken(privateToken) : null;

        if (newToken) {
            privateToken = newToken;
            **setToken(newToken)**
        } else {
            localStorage.removeItem(localStorageKey);
            privateToken = null;
        }
    }
};
obabichev commented 4 years ago

Thanks a lot for the fix, I updated the version on npm to 1.1.4