There is a problem with userToken caching. When restoring token from SecureStore we should check, if it's still valid. Currently there is no backend endpoint to validate token. There is a way to validate token e.g. fetch /flats, but it's not an elegant solution. When backend team implemented endpoint to validate token, this issue should be resolved.
// App.tsx
React.useEffect(() => {
(async () => {
let userToken: string | null;
try {
userToken = await SecureStore.getItemAsync("userToken");
} catch {
// Token was not found in the secure store. User is not authenticated.
userToken = null;
}
dispatch({ type: "RESTORE_TOKEN", token: userToken });
})();
}, []);
There is a problem with userToken caching. When restoring token from SecureStore we should check, if it's still valid. Currently there is no backend endpoint to validate token. There is a way to validate token e.g. fetch
/flats
, but it's not an elegant solution. When backend team implemented endpoint to validate token, this issue should be resolved.