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.

index.tsx 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import * as React from 'react'
  2. import type { GetServerSideProps } from 'next'
  3. import { getSession } from 'next-auth/client'
  4. import type { Session } from 'next-auth'
  5. import { signOut } from 'next-auth/client'
  6. import Head from 'next/head'
  7. interface UserPageProps {
  8. session: Session
  9. }
  10. export default function UserPage({ session }: UserPageProps): JSX.Element {
  11. return (
  12. <>
  13. <Head>
  14. <title>tldraw</title>
  15. </Head>
  16. <div>
  17. <pre>
  18. <code>{JSON.stringify(session.user, null, 2)}</code>
  19. </pre>
  20. <button onClick={() => signOut}>Sign Out</button>
  21. </div>
  22. </>
  23. )
  24. }
  25. export const getServerSideProps: GetServerSideProps = async (context) => {
  26. const session = await getSession(context)
  27. if (!session?.user && process.env.NODE_ENV !== 'development') {
  28. context.res.setHeader('Location', `/sponsorware`)
  29. context.res.statusCode = 307
  30. }
  31. const id = context.query.id?.toString()
  32. // Get document from database
  33. // If document does not exist, create an empty document
  34. // Return the document
  35. return {
  36. props: {
  37. id,
  38. session,
  39. },
  40. }
  41. }