You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth-test.tsx 921B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import Head from 'next/head'
  2. import { signIn, signOut, getSession, useSession } from 'next-auth/client'
  3. import { GetServerSidePropsContext } from 'next'
  4. export default function Home({
  5. ssrSession,
  6. isOwner,
  7. isSponsor,
  8. }: {
  9. isOwner: boolean
  10. isSponsor: boolean
  11. ssrSession: any
  12. }) {
  13. const [session, loading] = useSession()
  14. return (
  15. <>
  16. <Head>
  17. <title>tldraw</title>
  18. </Head>
  19. <div>
  20. <button onClick={() => signIn()}>Sign In</button>
  21. <button onClick={() => signOut()}>Sign Out</button>
  22. <p>{loading && 'Loading...'}</p>
  23. <pre>{JSON.stringify(session, null, 2)}</pre>
  24. {session && <p>Hey, you made it! Thanks for sponsoring me.</p>}
  25. </div>
  26. </>
  27. )
  28. }
  29. export async function getServerSideProps(context: GetServerSidePropsContext) {
  30. const session = await getSession(context)
  31. return {
  32. props: {
  33. ssrSession: session,
  34. },
  35. }
  36. }