From e7db0ccb70fb3acb985998cff340c910527ea9c6 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Feb 2025 02:57:49 -0600 Subject: [PATCH] refactor: update invitation --- .../components/dashboard/search-command.tsx | 2 +- .../git/github/add-github-provider.tsx | 8 +- .../dashboard/settings/users/add-user.tsx | 28 ++-- apps/dokploy/lib/auth.ts | 2 +- .../accept-invitation/[accept-invitation].tsx | 30 ++++ .../pages/api/providers/github/setup.ts | 17 +- apps/dokploy/server/api/routers/bitbucket.ts | 36 ++--- apps/dokploy/server/api/routers/github.ts | 24 +-- apps/dokploy/server/api/routers/gitlab.ts | 19 +-- apps/dokploy/server/api/routers/project.ts | 2 +- apps/dokploy/server/api/routers/user.ts | 2 +- apps/dokploy/server/server.ts | 16 +- .../server/wss/docker-container-logs.ts | 4 +- .../server/wss/docker-container-terminal.ts | 4 +- apps/dokploy/server/wss/docker-stats.ts | 4 +- apps/dokploy/server/wss/drawer-logs.ts | 7 + apps/dokploy/server/wss/listen-deployment.ts | 4 +- apps/dokploy/server/wss/terminal.ts | 8 +- packages/server/src/auth/auth.ts | 78 ---------- packages/server/src/auth/token.ts | 146 +++++++++--------- packages/server/src/lib/auth.ts | 17 +- packages/server/src/services/application.ts | 56 +++---- packages/server/src/services/compose.ts | 40 ++--- .../server/src/services/preview-deployment.ts | 6 +- packages/server/src/services/settings.ts | 2 - packages/server/src/services/user.ts | 22 +-- .../src/utils/notifications/build-error.ts | 6 +- .../src/utils/notifications/build-success.ts | 6 +- .../src/utils/notifications/docker-cleanup.ts | 4 +- 29 files changed, 270 insertions(+), 330 deletions(-) create mode 100644 apps/dokploy/pages/accept-invitation/[accept-invitation].tsx diff --git a/apps/dokploy/components/dashboard/search-command.tsx b/apps/dokploy/components/dashboard/search-command.tsx index 952bbe5c8..8158a9ca8 100644 --- a/apps/dokploy/components/dashboard/search-command.tsx +++ b/apps/dokploy/components/dashboard/search-command.tsx @@ -36,7 +36,7 @@ export const SearchCommand = () => { const router = useRouter(); const [open, setOpen] = React.useState(false); const [search, setSearch] = React.useState(""); - const { data: session } = authClient.getSession(); + const { data: session } = authClient.useSession(); const { data } = api.project.all.useQuery(undefined, { enabled: !!session, }); diff --git a/apps/dokploy/components/dashboard/settings/git/github/add-github-provider.tsx b/apps/dokploy/components/dashboard/settings/git/github/add-github-provider.tsx index 0e3e56336..5f2cb934d 100644 --- a/apps/dokploy/components/dashboard/settings/git/github/add-github-provider.tsx +++ b/apps/dokploy/components/dashboard/settings/git/github/add-github-provider.tsx @@ -10,12 +10,14 @@ import { } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; +import { authClient } from "@/lib/auth"; import { api } from "@/utils/api"; import { format } from "date-fns"; import { useEffect, useState } from "react"; export const AddGithubProvider = () => { const [isOpen, setIsOpen] = useState(false); + const { data: activeOrganization } = authClient.useActiveOrganization(); const { data } = api.auth.get.useQuery(); const [manifest, setManifest] = useState(""); const [isOrganization, setIsOrganization] = useState(false); @@ -25,7 +27,7 @@ export const AddGithubProvider = () => { const url = document.location.origin; const manifest = JSON.stringify( { - redirect_url: `${origin}/api/providers/github/setup?authId=${data?.id}`, + redirect_url: `${origin}/api/providers/github/setup?organizationId=${activeOrganization?.id}`, name: `Dokploy-${format(new Date(), "yyyy-MM-dd")}`, url: origin, hook_attributes: { @@ -93,8 +95,8 @@ export const AddGithubProvider = () => {