mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: add organization invitation system and update user profile management
This commit is contained in:
@@ -81,7 +81,11 @@ export const applicationRouter = createTRPCRouter({
|
||||
const newApplication = await createApplication(input);
|
||||
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newApplication.applicationId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newApplication.applicationId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
return newApplication;
|
||||
} catch (error: unknown) {
|
||||
|
||||
@@ -80,7 +80,11 @@ export const composeRouter = createTRPCRouter({
|
||||
const newService = await createCompose(input);
|
||||
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newService.composeId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newService.composeId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
return newService;
|
||||
@@ -424,7 +428,11 @@ export const composeRouter = createTRPCRouter({
|
||||
});
|
||||
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, compose.composeId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
compose.composeId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
if (mounts && mounts?.length > 0) {
|
||||
|
||||
@@ -57,7 +57,11 @@ export const mariadbRouter = createTRPCRouter({
|
||||
}
|
||||
const newMariadb = await createMariadb(input);
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newMariadb.mariadbId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newMariadb.mariadbId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
await createMount({
|
||||
|
||||
@@ -56,7 +56,11 @@ export const mongoRouter = createTRPCRouter({
|
||||
}
|
||||
const newMongo = await createMongo(input);
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newMongo.mongoId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newMongo.mongoId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
await createMount({
|
||||
|
||||
@@ -59,7 +59,11 @@ export const mysqlRouter = createTRPCRouter({
|
||||
|
||||
const newMysql = await createMysql(input);
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newMysql.mysqlId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newMysql.mysqlId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
await createMount({
|
||||
|
||||
@@ -64,7 +64,11 @@ export const postgresRouter = createTRPCRouter({
|
||||
}
|
||||
const newPostgres = await createPostgres(input);
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newPostgres.postgresId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newPostgres.postgresId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
await createMount({
|
||||
|
||||
@@ -56,7 +56,11 @@ export const redisRouter = createTRPCRouter({
|
||||
}
|
||||
const newRedis = await createRedis(input);
|
||||
if (ctx.user.rol === "member") {
|
||||
await addNewService(ctx.user.id, newRedis.redisId);
|
||||
await addNewService(
|
||||
ctx.user.id,
|
||||
newRedis.redisId,
|
||||
project.organizationId,
|
||||
);
|
||||
}
|
||||
|
||||
await createMount({
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { adminProcedure, createTRPCRouter, protectedProcedure } from "../trpc";
|
||||
|
||||
import { db } from "@/server/db";
|
||||
export const registryRouter = createTRPCRouter({
|
||||
create: adminProcedure
|
||||
.input(apiCreateRegistry)
|
||||
|
||||
@@ -15,10 +15,11 @@ import {
|
||||
apiAssignPermissions,
|
||||
apiFindOneToken,
|
||||
apiUpdateUser,
|
||||
invitation,
|
||||
member,
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { and, asc, desc, eq } from "drizzle-orm";
|
||||
import { and, asc, desc, eq, gt } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
adminProcedure,
|
||||
@@ -115,14 +116,34 @@ export const userRouter = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
|
||||
const { id, ...rest } = input;
|
||||
|
||||
console.log(rest);
|
||||
await db
|
||||
.update(member)
|
||||
.set({
|
||||
...input,
|
||||
...rest,
|
||||
})
|
||||
.where(eq(member.userId, input.id));
|
||||
.where(
|
||||
and(
|
||||
eq(member.userId, input.id),
|
||||
eq(
|
||||
member.organizationId,
|
||||
ctx.session?.activeOrganizationId || "",
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}),
|
||||
getInvitations: protectedProcedure.query(async ({ ctx }) => {
|
||||
return await db.query.invitation.findMany({
|
||||
where: and(
|
||||
eq(invitation.email, ctx.user.email),
|
||||
gt(invitation.expiresAt, new Date()),
|
||||
eq(invitation.status, "pending"),
|
||||
),
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user