Authentication Added
This commit is contained in:
@@ -1,30 +1,33 @@
|
|||||||
"use client";
|
import { auth0 } from "@/lib/auth0";
|
||||||
import Image from "next/image";
|
import './globals.css';
|
||||||
|
|
||||||
function Mobile() {
|
export default async function Home() {
|
||||||
return (
|
// Fetch the user session
|
||||||
<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)]">
|
const session = await auth0.getSession();
|
||||||
<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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Web() {
|
// If no session, show sign-up and login buttons
|
||||||
return (
|
if (!session) {
|
||||||
<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)]">
|
return (
|
||||||
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
|
<main>
|
||||||
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
<a href="/auth/login?screen_hint=signup">
|
||||||
Welcome to Web.s!
|
<button>Sign up</button>
|
||||||
</h1>
|
</a>
|
||||||
</main>
|
<a href="/auth/login">
|
||||||
</div>
|
<button>Log in</button>
|
||||||
);
|
</a>
|
||||||
}
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Home() {
|
// If session exists, show a welcome message and logout button
|
||||||
return Mobile();
|
return (
|
||||||
}
|
<main>
|
||||||
|
<h1>Welcome, {session.user.name}!</h1>
|
||||||
|
<p>
|
||||||
|
<a href="/auth/logout">
|
||||||
|
<button>Log out</button>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import { auth0 } from "./lib/auth0"
|
import { auth0 } from "./lib/auth0";
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
return await auth0.middleware(request);
|
return await auth0.middleware(request);
|
||||||
|
|||||||
Reference in New Issue
Block a user