From b7fc3344e3f3c898388831dbfad084cebdd64bb3 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 5 Feb 2024 17:07:32 +0000 Subject: Init NextAuth --- app/api/auth/[...nextauth]/route.tsx | 21 +++++++ app/page.tsx | 112 +++-------------------------------- 2 files changed, 28 insertions(+), 105 deletions(-) create mode 100644 app/api/auth/[...nextauth]/route.tsx (limited to 'app') diff --git a/app/api/auth/[...nextauth]/route.tsx b/app/api/auth/[...nextauth]/route.tsx new file mode 100644 index 00000000..b9decb30 --- /dev/null +++ b/app/api/auth/[...nextauth]/route.tsx @@ -0,0 +1,21 @@ +import NextAuth from "next-auth" +import { PrismaAdapter } from "@next-auth/prisma-adapter" +import AuthentikProvider from "next-auth/providers/authentik"; +import { PrismaClient } from "@prisma/client" +import serverConfig from "@/lib/config"; + +const prisma = new PrismaClient() + +let providers = []; + +if (serverConfig.auth.authentik) { + providers.push(AuthentikProvider(serverConfig.auth.authentik)); +} + +const handler = NextAuth({ + // Configure one or more authentication providers + adapter: PrismaAdapter(prisma), + providers: providers, +}); + +export { handler as GET, handler as POST } diff --git a/app/page.tsx b/app/page.tsx index dc191aa8..2df40508 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,112 +1,14 @@ -import Image from "next/image"; +import { LoginButton } from "../components/auth/login"; +import { LogoutButton } from "../components/auth/logout"; export default function Home() { return (
-
-

- Get started by editing  - app/page.tsx -

-
- - By{" "} - Vercel Logo - -
-
- -
- Next.js Logo -
- -
- -

- Docs{" "} - - -> - -

-

- Find in-depth information about Next.js features and API. -

-
- - -

- Learn{" "} - - -> - -

-

- Learn about Next.js in an interactive course with quizzes! -

-
- - -

- Templates{" "} - - -> - -

-

- Explore starter templates for Next.js. -

-
- - -

- Deploy{" "} - - -> - -

-

- Instantly deploy your Next.js site to a shareable URL with Vercel. -

-
+
+ +
+
+
); -- cgit v1.2.3-70-g09d2