Skip to content

Commit

Permalink
do logout from rewards service only if token is preset
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Dec 17, 2024
1 parent 3a400a1 commit 41120b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ui/snippets/auth/useLogout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export default function useLogout() {

if (config.features.rewards.isEnabled) {
const rewardsToken = cookies.get(cookies.NAMES.REWARDS_API_TOKEN);
await apiFetch('rewards_logout', { fetchParams: {
method: 'POST',
headers: { Authorization: `Bearer ${ rewardsToken }` },
} });
cookies.remove(cookies.NAMES.REWARDS_API_TOKEN);
if (rewardsToken) {
await apiFetch('rewards_logout', { fetchParams: {
method: 'POST',
headers: { Authorization: `Bearer ${ rewardsToken }` },
} });
cookies.remove(cookies.NAMES.REWARDS_API_TOKEN);
}
}

queryClient.resetQueries({
Expand Down

0 comments on commit 41120b4

Please sign in to comment.