From 4fde7018f2ce58f64dbc77da82cd12406ff57d4c Mon Sep 17 00:00:00 2001 From: Thomas Makin Date: Wed, 27 Mar 2024 21:26:28 -0400 Subject: [PATCH] implement login and settings load --- app/NextAuthProvider.tsx | 10 ++ app/api/auth/[...nextauth]/route.ts | 7 + app/layout.tsx | 23 +-- app/page.tsx | 44 +++-- app/settings/page.tsx | 159 ++++++++++++------ components/card.tsx | 40 ++--- components/cardbody.tsx | 52 ++++-- components/forceSignIn.tsx | 21 +++ components/pagebody.tsx | 2 +- docker-compose.debug.yml | 3 + lib/auth.ts | 37 ++++ package-lock.json | 131 +++++++++++++++ package.json | 1 + ...ent_settings.txt => student_settings.json} | 0 14 files changed, 419 insertions(+), 111 deletions(-) create mode 100644 app/NextAuthProvider.tsx create mode 100644 app/api/auth/[...nextauth]/route.ts create mode 100644 components/forceSignIn.tsx create mode 100644 lib/auth.ts rename student_settings/{student_settings.txt => student_settings.json} (100%) diff --git a/app/NextAuthProvider.tsx b/app/NextAuthProvider.tsx new file mode 100644 index 0000000..3dfb236 --- /dev/null +++ b/app/NextAuthProvider.tsx @@ -0,0 +1,10 @@ +"use client" // SessionProvider needs to wrap around a client component to be used in layout.tsx, cannot be used directly in layout.tsx +import { SessionProvider } from "next-auth/react"; + +type Props = { + children?: React.ReactNode; +}; + +export const NextAuthProvider = ({ children }: Props) => { + return {children}; +}; diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..18b0805 --- /dev/null +++ b/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,7 @@ +export const dynamic = 'force-dynamic' // defaults to auto +import NextAuth from "next-auth"; +import { config } from "../../../../lib/auth"; + +const handler = NextAuth(config) + +export { handler as GET, handler as POST } diff --git a/app/layout.tsx b/app/layout.tsx index 8e29d79..9d774ec 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,6 +1,7 @@ import Nav from '@/components/nav' import './globals.css' import Script from 'next/script' +import { NextAuthProvider } from './NextAuthProvider'; export const metadata = { title: 'Cygnet', @@ -13,15 +14,17 @@ export default function RootLayout({ children: React.ReactNode }) { return ( - - -