mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-29 08:12:15 +00:00
refactor: enhance access control in environment, mount, port, rollback, and schedule routers to ensure users can only interact with resources belonging to their organization
This commit is contained in:
@@ -35,9 +35,29 @@ export const findScheduleById = async (scheduleId: string) => {
|
||||
const schedule = await db.query.schedules.findFirst({
|
||||
where: eq(schedules.scheduleId, scheduleId),
|
||||
with: {
|
||||
application: true,
|
||||
compose: true,
|
||||
server: true,
|
||||
application: {
|
||||
with: {
|
||||
environment: {
|
||||
with: {
|
||||
project: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
compose: {
|
||||
with: {
|
||||
environment: {
|
||||
with: {
|
||||
project: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
with: {
|
||||
organization: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -50,6 +70,21 @@ export const findScheduleById = async (scheduleId: string) => {
|
||||
return schedule;
|
||||
};
|
||||
|
||||
export const findScheduleOrganizationId = async (scheduleId: string) => {
|
||||
const schedule = await findScheduleById(scheduleId);
|
||||
|
||||
if (schedule?.application) {
|
||||
return schedule?.application?.environment?.project?.organizationId;
|
||||
}
|
||||
if (schedule?.compose) {
|
||||
return schedule?.compose?.environment?.project?.organizationId;
|
||||
}
|
||||
if (schedule?.server) {
|
||||
return schedule?.server?.organization?.id;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const deleteSchedule = async (scheduleId: string) => {
|
||||
const schedule = await findScheduleById(scheduleId);
|
||||
const serverId =
|
||||
|
||||
Reference in New Issue
Block a user