cookie's now only used under /admin

This commit is contained in:
Thomas Ruoff
2024-09-11 23:44:31 +02:00
parent c671b622d5
commit af3262e55e
8 changed files with 77 additions and 61 deletions

25
helpers/withAuth.tsx Normal file
View File

@@ -0,0 +1,25 @@
import { SessionProvider } from 'next-auth/react'
import Auth from '../components/auth'
import User from '../components/user'
// This is the HOC
function withAuth(WrappedComponent) {
// Return a new component
function withAuth({ session, ...pageProps }) {
// Render the WrappedComponent with additional props
return (
<SessionProvider session={session}>
<Auth>
<User />
<WrappedComponent {...pageProps} />
</Auth>
</SessionProvider>
)
}
withAuth.displayName = `withAuth(${WrappedComponent.displayName}`
return withAuth
}
export default withAuth