Authentication Added
This commit is contained in:
@@ -1,30 +1,33 @@
|
||||
"use client";
|
||||
import Image from "next/image";
|
||||
import { auth0 } from "@/lib/auth0";
|
||||
import './globals.css';
|
||||
|
||||
function Mobile() {
|
||||
export default async function Home() {
|
||||
// Fetch the user session
|
||||
const session = await auth0.getSession();
|
||||
|
||||
// If no session, show sign-up and login buttons
|
||||
if (!session) {
|
||||
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>
|
||||
<a href="/auth/login?screen_hint=signup">
|
||||
<button>Sign up</button>
|
||||
</a>
|
||||
<a href="/auth/login">
|
||||
<button>Log in</button>
|
||||
</a>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Web() {
|
||||
// If session exists, show a welcome message and logout button
|
||||
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>
|
||||
<h1>Welcome, {session.user.name}!</h1>
|
||||
<p>
|
||||
<a href="/auth/logout">
|
||||
<button>Log out</button>
|
||||
</a>
|
||||
</p>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
return Mobile();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user