Skip to content

Commit

Permalink
Merge pull request #144 from bas-kirill/bugfix/do-not-access-favorite…
Browse files Browse the repository at this point in the history
…-during-expired-jwt

fix(catalogue): do not request favorite when jwt token expired
  • Loading branch information
bas-kirill authored Aug 29, 2024
2 parents 089a11b + 0ab6307 commit 0e3bad5
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export const FavoriteButton = (props: Props) => {
const [favorite, setFavorite] = useState<boolean>();

useEffect(() => {
if (jwt.current === undefined) {
return;
}
const fetchFavorite = async () => {
const favoriteRequest = await listFavorite.listFavorite({
withCredentials: true,
Expand All @@ -44,6 +41,10 @@ export const FavoriteButton = (props: Props) => {
setFavorite(favoriteRawIds.includes(instrumentId));
};

const jwt = Jwt.extractFromCookie();
if (jwt === null || jwt.expired()) {
return;
}
fetchFavorite();
}, []);

Expand Down

0 comments on commit 0e3bad5

Please sign in to comment.