From 9514b1be33d66fd0636767d07e33fe0c0af4296e Mon Sep 17 00:00:00 2001 From: SKULL-GOD Date: Sat, 12 Apr 2025 14:40:47 -0400 Subject: [PATCH] Authentication Added --- src/app/page.tsx | 57 +++++++++++++++++++++++++---------------------- src/middleware.ts | 2 +- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 361c8d2..6314119 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,30 +1,33 @@ -"use client"; -import Image from "next/image"; +import { auth0 } from "@/lib/auth0"; +import './globals.css'; -function Mobile() { - return ( -
-
-

- Welcome to Mobile.s! -

-
-
- ); -} +export default async function Home() { + // Fetch the user session + const session = await auth0.getSession(); -function Web() { - return ( -
-
-

- Welcome to Web.s! -

-
-
- ); -} + // If no session, show sign-up and login buttons + if (!session) { + return ( +
+ + + + + + +
+ ); + } -export default function Home() { - return Mobile(); -} + // If session exists, show a welcome message and logout button + return ( +
+

Welcome, {session.user.name}!

+

+ + + +

+
+ ); +} \ No newline at end of file diff --git a/src/middleware.ts b/src/middleware.ts index fd65d1c..6b63ae0 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,5 +1,5 @@ import type { NextRequest } from "next/server"; -import { auth0 } from "./lib/auth0" +import { auth0 } from "./lib/auth0"; export async function middleware(request: NextRequest) { return await auth0.middleware(request);