mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Refactoring
This commit is contained in:
+25
-1
@@ -52,6 +52,7 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
authMethod: "google",
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -66,8 +67,31 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
||||
callbacks: {
|
||||
session({session, user, token}) {
|
||||
// session.user.role = user.role
|
||||
// session.user.authMethod = user.authMethod;
|
||||
return session
|
||||
}
|
||||
},
|
||||
async signIn({ account, user }) {
|
||||
console.log(account)
|
||||
// const authMethod = account.provider === 'credentials' ? 'credentials' : 'oauth';
|
||||
user = await prisma.user.findFirst({
|
||||
where: {
|
||||
email: user.email,
|
||||
}
|
||||
})
|
||||
if (!user) {
|
||||
return true
|
||||
}
|
||||
console.log(user)
|
||||
// Update the user in the database with the auth method
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
authMethod: account.provider
|
||||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -13,27 +13,31 @@ import {
|
||||
} from "lucide-react";
|
||||
import {LoggedInButton} from "@/components/wrappers/Dashboard/LoggedInButton/LoggedInButton";
|
||||
import {SidebarMenuCustom} from "@/components/wrappers/Dashboard/SideBar/SideBarMenu/SideBarMenu";
|
||||
import Image from 'next/image';
|
||||
|
||||
export function AppSidebar() {
|
||||
|
||||
return (
|
||||
<Sidebar collapsible="icon">
|
||||
<SidebarHeader>
|
||||
<div className="flex justify-center items-center ">
|
||||
<h1 className="font-bold text-xl">Portabase</h1>
|
||||
</div>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<SidebarMenuButton>
|
||||
Select Workspace
|
||||
Select Project
|
||||
<ChevronDown className="ml-auto"/>
|
||||
</SidebarMenuButton>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-[--radix-popper-anchor-width]">
|
||||
<DropdownMenuItem>
|
||||
<span>Acme Inc</span>
|
||||
<span>Project 1</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<span>Acme Corp.</span>
|
||||
<span>Project 2</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
@@ -54,6 +58,9 @@ export function AppSidebar() {
|
||||
<LoggedInButton/>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
<div className="text-center">
|
||||
<h1 className="text-[10px]">Portabase Community Edition 1.0.0</h1>
|
||||
</div>
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user