This commit is contained in:
2026-06-24 14:20:05 +02:00
commit 1c859d20c8
442 changed files with 25625 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import { MeDocument } from '@/generated/graphql/graphql'
import { useQuery } from '@apollo/client/react'
import { usePathname, useRouter } from 'next/navigation'
import { useEffect } from 'react'
export const useAuthenticate = () => {
const router = useRouter()
const { data, loading } = useQuery(MeDocument)
const pathname = usePathname()
useEffect(() => {
if (!loading && !data?.me) {
router.replace(`/login?redirect=${pathname}`)
}
}, [router, data, loading])
}