User Auth Handling Update
This commit is contained in:
@@ -16,7 +16,7 @@ export default function RootLayout({
|
||||
<main className="max-h-screen max-w-screen bg-img overflow-hidden" suppressHydrationWarning={true}>
|
||||
{!isMobile && !isSafari ? <NavBar /> : null}
|
||||
<section className="space-x-2 gap-4 flex flex-col overflow-y-auto h-screen p-4 lg:p-6 lg:rounded-xl lg:shadow-sm">
|
||||
<img src="/drinkhappylogo.png" alt="Drink Happy Logo Image" className="h-auto mx-auto w-3/4 lg:w-1/4" />
|
||||
<img src="/drinkhappylogo.png" alt="Drink Happy Logo Image" className="h-auto mx-auto w-3/4 lg:w-2/3" />
|
||||
{children}
|
||||
</section>
|
||||
{isMobile && isSafari ? (
|
||||
|
||||
@@ -8,7 +8,7 @@ function Mobile() {
|
||||
return (
|
||||
<main className="flex flex-col gap-[32px] row-start-2 items-center mt-10">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
||||
Welcome, {isAuthenticated ? session.username : ""} !!
|
||||
{isAuthenticated ? `Welcome, ${session.username} !!` : ""}
|
||||
</h1>
|
||||
</main>
|
||||
);
|
||||
@@ -20,7 +20,7 @@ function Web() {
|
||||
return (
|
||||
<main className="flex flex-col row-start-2 items-center mt-10">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
||||
Welcome, {isAuthenticated ? session.username : ""} !!
|
||||
{isAuthenticated ? `Welcome, ${session.username} !!` : ""}
|
||||
</h1>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function GET() {
|
||||
const session = await auth0.getSession();
|
||||
|
||||
if (!session) {
|
||||
return NextResponse.json({ session: null }, { status: 401 });
|
||||
return NextResponse.json({ session: null }, { status: 200 });
|
||||
}
|
||||
|
||||
const sessionUser = session.user;
|
||||
@@ -17,8 +17,6 @@ export async function GET() {
|
||||
if (!userData) {
|
||||
console.log("User not found in database, creating new user...");
|
||||
userData = await db.users.create(sessionUser?.email as string, sessionUser?.nickname as string);
|
||||
} else {
|
||||
console.log("User found in database:", userData);
|
||||
}
|
||||
|
||||
return NextResponse.json({ session: userData });
|
||||
|
||||
@@ -27,11 +27,7 @@ export const DeviceProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
const res = await fetch("/auth/session");
|
||||
const data = await res.json();
|
||||
|
||||
if (res.ok) {
|
||||
setSession(data.session);
|
||||
} else {
|
||||
console.error("Error fetching session:", data);
|
||||
}
|
||||
if (res.ok) setSession(data.session);
|
||||
};
|
||||
|
||||
checkAuthentication();
|
||||
|
||||
Reference in New Issue
Block a user