obabichev / react-token-auth

84 stars 22 forks source link

checkExpiry: remove duplicated deletion of key and allow notify() #22

Closed callmejed closed 3 years ago

callmejed commented 3 years ago

authFetch() uses checkExpiry() and assigns newToken if it exists, via setToken, or removes the key from default storage. setToken() already does this, as well as notify() the listener if the storage key was removed (i.e. set to null and storage.removeItem). Otherwise the useAuth() is unable to detect a change and reports user isLoggedIn even when there is no 'REACT_TOKEN_AUTH_KEY' in storage.

obabichev commented 3 years ago

Thank you a lot for the fix. Glat to see that the tool is used. I will merge it and update npm package

obabichev commented 3 years ago

Version 1.1.9 is available now

callmejed commented 3 years ago

Great, thanks!