mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-02 03:38:22 +00:00
Refactor authentication components and enhance user session handling
- Updated AccountPopover to utilize session data for user information display. - Modified ApplicationLayout to fetch user details from the database using Prisma. - Replaced Checkbox components with native input elements in SignUpForm for better accessibility. - Enhanced seed script to include default islands and create related data in the database.
This commit is contained in:
@ -15,6 +15,7 @@ import {
|
||||
SidebarTrigger,
|
||||
} from "@/components/ui/sidebar";
|
||||
import { auth } from "@/lib/auth";
|
||||
import prisma from "@/lib/db";
|
||||
import { headers } from "next/headers";
|
||||
import { AccountPopover } from "./account-popver";
|
||||
|
||||
@ -22,7 +23,12 @@ export async function ApplicationLayout({
|
||||
children,
|
||||
}: { children: React.ReactNode }) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: await headers(), // you need to pass the headers object.
|
||||
headers: await headers()
|
||||
});
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: session?.user?.id,
|
||||
},
|
||||
});
|
||||
return (
|
||||
<SidebarProvider>
|
||||
@ -47,7 +53,7 @@ export async function ApplicationLayout({
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<ModeToggle />
|
||||
<AccountPopover user={session?.user} />
|
||||
<AccountPopover user={user || undefined} />
|
||||
</div>
|
||||
</header>
|
||||
<div className="p-4">{children}</div>
|
||||
|
Reference in New Issue
Block a user