mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Refactoring
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// next-auth.d.ts
|
||||||
|
import NextAuth from "next-auth";
|
||||||
|
|
||||||
|
declare module "next-auth" {
|
||||||
|
interface Session {
|
||||||
|
user: {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
name: string;
|
||||||
|
authMethod: string; // Add authMethod to the session user type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
name: string;
|
||||||
|
authMethod: string; // Add authMethod to the user type
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+8744
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/prisma-adapter": "^2.4.1",
|
"@auth/prisma-adapter": "^2.4.1",
|
||||||
"@hookform/resolvers": "^3.9.1",
|
"@hookform/resolvers": "^3.9.1",
|
||||||
"@prisma/client": "^5.21.1",
|
"@prisma/client": "^5.22.0",
|
||||||
"@radix-ui/react-accordion": "^1.2.1",
|
"@radix-ui/react-accordion": "^1.2.1",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.2",
|
"@radix-ui/react-alert-dialog": "^1.1.2",
|
||||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||||
@@ -56,9 +56,9 @@
|
|||||||
"next-intl": "^3.24.0",
|
"next-intl": "^3.24.0",
|
||||||
"next-safe-action": "^7.4.3",
|
"next-safe-action": "^7.4.3",
|
||||||
"next-themes": "^0.3.0",
|
"next-themes": "^0.3.0",
|
||||||
"react": "19.0.0-rc-66855b96-20241106",
|
"react": "^18",
|
||||||
"react-day-picker": "^8.10.1",
|
"react-day-picker": "^8.10.1",
|
||||||
"react-dom": "19.0.0-rc-66855b96-20241106",
|
"react-dom": "^18",
|
||||||
"react-hook-form": "^7.53.1",
|
"react-hook-form": "^7.53.1",
|
||||||
"react-resizable-panels": "^2.1.6",
|
"react-resizable-panels": "^2.1.6",
|
||||||
"react-twc": "^1.4.2",
|
"react-twc": "^1.4.2",
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-config-next": "15.0.3",
|
"eslint-config-next": "15.0.3",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
"prisma": "^5.21.1",
|
"prisma": "^5.22.0",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "Status" AS ENUM ('waiting', 'ongoing', 'failed', 'success');
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Agent" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"last_contact" TIMESTAMP(3),
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "Agent_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Database" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"agent_id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"backup_policy" TEXT,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "Database_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Backup" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"database_id" TEXT NOT NULL,
|
||||||
|
"status" "Status" NOT NULL DEFAULT 'waiting',
|
||||||
|
"file" TEXT,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "Backup_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Restore" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"backup_id" TEXT NOT NULL,
|
||||||
|
"status" "Status" NOT NULL DEFAULT 'waiting',
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "Restore_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
@@ -62,11 +62,11 @@ model User {
|
|||||||
role String?
|
role String?
|
||||||
password String?
|
password String?
|
||||||
|
|
||||||
accounts Account[]
|
accounts Account[]
|
||||||
sessions Session[]
|
sessions Session[]
|
||||||
|
authMethod String?
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||||
|
|
||||||
@@map("users")
|
@@map("users")
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-1
@@ -52,6 +52,7 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
|||||||
name: profile.name,
|
name: profile.name,
|
||||||
email: profile.email,
|
email: profile.email,
|
||||||
image: profile.picture,
|
image: profile.picture,
|
||||||
|
authMethod: "google",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -66,8 +67,31 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
|||||||
callbacks: {
|
callbacks: {
|
||||||
session({session, user, token}) {
|
session({session, user, token}) {
|
||||||
// session.user.role = user.role
|
// session.user.role = user.role
|
||||||
|
// session.user.authMethod = user.authMethod;
|
||||||
return session
|
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";
|
} from "lucide-react";
|
||||||
import {LoggedInButton} from "@/components/wrappers/Dashboard/LoggedInButton/LoggedInButton";
|
import {LoggedInButton} from "@/components/wrappers/Dashboard/LoggedInButton/LoggedInButton";
|
||||||
import {SidebarMenuCustom} from "@/components/wrappers/Dashboard/SideBar/SideBarMenu/SideBarMenu";
|
import {SidebarMenuCustom} from "@/components/wrappers/Dashboard/SideBar/SideBarMenu/SideBarMenu";
|
||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
export function AppSidebar() {
|
export function AppSidebar() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar collapsible="icon">
|
<Sidebar collapsible="icon">
|
||||||
<SidebarHeader>
|
<SidebarHeader>
|
||||||
|
<div className="flex justify-center items-center ">
|
||||||
|
<h1 className="font-bold text-xl">Portabase</h1>
|
||||||
|
</div>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<SidebarMenuButton>
|
<SidebarMenuButton>
|
||||||
Select Workspace
|
Select Project
|
||||||
<ChevronDown className="ml-auto"/>
|
<ChevronDown className="ml-auto"/>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent className="w-[--radix-popper-anchor-width]">
|
<DropdownMenuContent className="w-[--radix-popper-anchor-width]">
|
||||||
<DropdownMenuItem>
|
<DropdownMenuItem>
|
||||||
<span>Acme Inc</span>
|
<span>Project 1</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem>
|
<DropdownMenuItem>
|
||||||
<span>Acme Corp.</span>
|
<span>Project 2</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
@@ -54,6 +58,9 @@ export function AppSidebar() {
|
|||||||
<LoggedInButton/>
|
<LoggedInButton/>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
</SidebarMenu>
|
</SidebarMenu>
|
||||||
|
<div className="text-center">
|
||||||
|
<h1 className="text-[10px]">Portabase Community Edition 1.0.0</h1>
|
||||||
|
</div>
|
||||||
</SidebarFooter>
|
</SidebarFooter>
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user