Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
Regnerate JWT Token on refresh (#344)
Browse files Browse the repository at this point in the history
* make sure to regenerate JWT on relogin

* don't refetch user on focus/reconnect
  • Loading branch information
FinnIckler authored Nov 27, 2023
1 parent 7625024 commit 60e2652
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Frontend/src/ui/providers/UserProvider.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import React from 'react'
import { getJWT } from '../../api/auth/get_jwt'
import { UserContext } from '../../api/helper/context/user_context'
import getMe from '../../api/user/get/get_me'
import LoadingMessage from '../messages/loadingMessage'
Expand All @@ -12,9 +13,15 @@ export default function UserProvider({ children }) {
queryKey: ['user-me'],
queryFn: () => getMe(),
retry: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
onError: (_) => {
// We are not logged in, set user explicitly to undefined?
},
onSuccess: (_) => {
// Get a new token so when a user switches account it overwrites the token
getJWT(true)
},
})
return isLoading ? (
<LoadingMessage />
Expand Down

0 comments on commit 60e2652

Please sign in to comment.