mirror of
https://github.com/LukeHagar/dokploy.git
synced 2025-12-09 20:37:45 +00:00
refactor: update organization context in API routers
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
|||||||
DropdownMenuLabel,
|
DropdownMenuLabel,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import copy from "copy-to-clipboard";
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -26,6 +25,7 @@ import {
|
|||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
import copy from "copy-to-clipboard";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { Mail, MoreHorizontal, Users } from "lucide-react";
|
import { Mail, MoreHorizontal, Users } from "lucide-react";
|
||||||
import { Loader2 } from "lucide-react";
|
import { Loader2 } from "lucide-react";
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const bitbucketRouter = createTRPCRouter({
|
|||||||
.input(apiCreateBitbucket)
|
.input(apiCreateBitbucket)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createBitbucket(input, ctx.user.ownerId);
|
return await createBitbucket(input, ctx.session.activeOrganizationId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export const destinationRouter = createTRPCRouter({
|
|||||||
.input(apiCreateDestination)
|
.input(apiCreateDestination)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createDestintation(input, ctx.user.ownerId);
|
return await createDestintation(
|
||||||
|
input,
|
||||||
|
ctx.session.activeOrganizationId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
@@ -111,7 +114,7 @@ export const destinationRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
return await removeDestinationById(
|
return await removeDestinationById(
|
||||||
input.destinationId,
|
input.destinationId,
|
||||||
ctx.user.ownerId,
|
ctx.session.activeOrganizationId,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const gitlabRouter = createTRPCRouter({
|
|||||||
.input(apiCreateGitlab)
|
.input(apiCreateGitlab)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createGitlab(input, ctx.user.ownerId);
|
return await createGitlab(input, ctx.session.activeOrganizationId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
|
|||||||
@@ -110,7 +110,10 @@ export const notificationRouter = createTRPCRouter({
|
|||||||
.input(apiCreateTelegram)
|
.input(apiCreateTelegram)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createTelegramNotification(input, ctx.user.ownerId);
|
return await createTelegramNotification(
|
||||||
|
input,
|
||||||
|
ctx.session.activeOrganizationId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
@@ -162,7 +165,10 @@ export const notificationRouter = createTRPCRouter({
|
|||||||
.input(apiCreateDiscord)
|
.input(apiCreateDiscord)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createDiscordNotification(input, ctx.user.ownerId);
|
return await createDiscordNotification(
|
||||||
|
input,
|
||||||
|
ctx.session.activeOrganizationId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
@@ -223,7 +229,10 @@ export const notificationRouter = createTRPCRouter({
|
|||||||
.input(apiCreateEmail)
|
.input(apiCreateEmail)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createEmailNotification(input, ctx.user.ownerId);
|
return await createEmailNotification(
|
||||||
|
input,
|
||||||
|
ctx.session.activeOrganizationId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
@@ -388,7 +397,10 @@ export const notificationRouter = createTRPCRouter({
|
|||||||
.input(apiCreateGotify)
|
.input(apiCreateGotify)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
return await createGotifyNotification(input, ctx.user.ownerId);
|
return await createGotifyNotification(
|
||||||
|
input,
|
||||||
|
ctx.session.activeOrganizationId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import {
|
|||||||
organization,
|
organization,
|
||||||
users_temp,
|
users_temp,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
|
import { IS_CLOUD, auth } from "@dokploy/server/index";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { and, desc, eq, exists } from "drizzle-orm";
|
import { and, desc, eq, exists } from "drizzle-orm";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { adminProcedure, createTRPCRouter, protectedProcedure } from "../trpc";
|
import { adminProcedure, createTRPCRouter, protectedProcedure } from "../trpc";
|
||||||
import { auth, IS_CLOUD } from "@dokploy/server/index";
|
|
||||||
export const organizationRouter = createTRPCRouter({
|
export const organizationRouter = createTRPCRouter({
|
||||||
create: protectedProcedure
|
create: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
@@ -148,10 +148,9 @@ export const organizationRouter = createTRPCRouter({
|
|||||||
acceptInvitation: adminProcedure
|
acceptInvitation: adminProcedure
|
||||||
.input(z.object({ invitationId: z.string() }))
|
.input(z.object({ invitationId: z.string() }))
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
const result = await auth.api.acceptInvitation({
|
// const result = await auth.api.acceptInvitation({
|
||||||
invitationId: input.invitationId,
|
// invitationId: input.invitationId,
|
||||||
});
|
// });
|
||||||
|
// return result;
|
||||||
return result;
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
// import { getServerAuthSession } from "@/server/auth";
|
// import { getServerAuthSession } from "@/server/auth";
|
||||||
import { db } from "@/server/db";
|
import { db } from "@/server/db";
|
||||||
import { validateBearerToken } from "@dokploy/server";
|
|
||||||
import { validateRequest } from "@dokploy/server/lib/auth";
|
import { validateRequest } from "@dokploy/server/lib/auth";
|
||||||
import type { OpenApiMeta } from "@dokploy/trpc-openapi";
|
import type { OpenApiMeta } from "@dokploy/trpc-openapi";
|
||||||
import { TRPCError, initTRPC } from "@trpc/server";
|
import { TRPCError, initTRPC } from "@trpc/server";
|
||||||
|
|||||||
Reference in New Issue
Block a user