login logout redirects, session, remove out of scope code

This commit is contained in:
Timur Ercan
2023-01-04 14:37:33 +01:00
parent dd36e8d161
commit fe2219dcd2
6 changed files with 24 additions and 174 deletions

View File

@ -2,6 +2,7 @@ import "../styles/tailwind.css";
import { ReactElement, ReactNode } from "react";
import type { AppProps } from "next/app";
import { NextPage } from "next";
import { SessionProvider } from "next-auth/react";
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
@ -11,7 +12,14 @@ type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
export default function App({ Component, pageProps }: AppPropsWithLayout) {
export default function App({
Component,
pageProps: { session, ...pageProps },
}: AppPropsWithLayout) {
const getLayout = Component.getLayout || ((page: any) => page);
return getLayout(<Component {...pageProps} />);
return getLayout(
<SessionProvider session={session}>
<Component {...pageProps} />{" "}
</SessionProvider>
);
}