Update auth-test.tsx

feature/ste-6-copy-as-svg
Steve Ruiz 2021-06-20 09:02:37 +01:00
rodzic 519ba182d6
commit 9de38aa9da
1 zmienionych plików z 3 dodań i 17 usunięć

Wyświetl plik

@ -2,8 +2,8 @@ import Head from 'next/head'
import { signIn, signOut, getSession, useSession } from 'next-auth/client'
import { GetServerSidePropsContext } from 'next'
export default function Home({ session }: any) {
// const [session, loading] = useSession()
export default function Home() {
const [session, loading] = useSession()
return (
<>
<Head>
@ -13,23 +13,9 @@ export default function Home({ session }: any) {
<button onClick={() => signIn()}>Sign In</button>
<button onClick={() => signOut()}>Sign Out</button>
<pre>{JSON.stringify(session, null, 2)}</pre>
{loading && 'Loading...'}
{session && <p>Hey, you made it! Thanks for sponsoring me.</p>}
</div>
</>
)
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
const session = await getSession(context)
.then((c) => {
console.log(c)
return c
})
.catch((e) => console.log(e))
return {
props: {
session,
},
}
}