fix: session auth issues

This commit is contained in:
swve 2024-05-27 20:58:32 +02:00
parent 1708b36818
commit 08cc97f557
70 changed files with 607 additions and 427 deletions

View file

@ -0,0 +1,33 @@
'use client'
import PageLoading from '@components/Objects/Loaders/PageLoading';
import { useSession } from 'next-auth/react';
import React, { useContext, createContext, useEffect } from 'react'
export const SessionContext = createContext({}) as any
function LHSessionProvider({ children }: { children: React.ReactNode }) {
const session = useSession();
useEffect(() => {
console.log('useLHSession', session);
}, [session])
if (session.status == 'loading') {
return <PageLoading />
}
else {
return (
<SessionContext.Provider value={session}>
{children}
</SessionContext.Provider>
)
}
}
export function useLHSession() {
return useContext(SessionContext)
}
export default LHSessionProvider