Authentication Added

This commit is contained in:
SKULL-GOD
2025-04-12 14:40:47 -04:00
parent 92f84eebb7
commit 9514b1be33
2 changed files with 31 additions and 28 deletions

View File

@@ -1,30 +1,33 @@
"use client";
import Image from "next/image";
import { auth0 } from "@/lib/auth0";
import './globals.css';
function Mobile() {
return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
Welcome to Mobile.s!
</h1>
</main>
</div>
);
}
export default async function Home() {
// Fetch the user session
const session = await auth0.getSession();
function Web() {
return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
Welcome to Web.s!
</h1>
</main>
</div>
);
}
// If no session, show sign-up and login buttons
if (!session) {
return (
<main>
<a href="/auth/login?screen_hint=signup">
<button>Sign up</button>
</a>
<a href="/auth/login">
<button>Log in</button>
</a>
</main>
);
}
export default function Home() {
return Mobile();
}
// If session exists, show a welcome message and logout button
return (
<main>
<h1>Welcome, {session.user.name}!</h1>
<p>
<a href="/auth/logout">
<button>Log out</button>
</a>
</p>
</main>
);
}

View File

@@ -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);