mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: session auth issues
This commit is contained in:
parent
1708b36818
commit
08cc97f557
70 changed files with 607 additions and 427 deletions
33
apps/web/components/Contexts/LHSessionContext.tsx
Normal file
33
apps/web/components/Contexts/LHSessionContext.tsx
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue