fix: can't edit ooo (#18020)

* fix: can't edit ooo

* fix: unauthorized users can edit ooo
This commit is contained in:
Kartik Saini authored and GitHub committed 2024-12-09 23:39:56 +00:00
1 parent 950879b9c7
commit 9c9d7fe0c3
2 files changed
+7 -1

No files matched your search

@@ -40,6 +40,10 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
let toUserId: number | null = null;
if (input.toTeamUserId === ctx.user.id) {
throw new TRPCError({ code: "BAD_REQUEST", message: "cannot_redirect_to_self" });
}
if (input.toTeamUserId) {
const user = await prisma.user.findUnique({
where: {
@@ -108,7 +112,7 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
},
});
if (isDuplicateOutOfOfficeEntry) {
if (isDuplicateOutOfOfficeEntry && isDuplicateOutOfOfficeEntry?.uuid !== input.uuid) {
throw new TRPCError({ code: "CONFLICT", message: "out_of_office_entry_already_exists" });
}
@@ -132,6 +136,7 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
const createdOrUpdatedOutOfOffice = await prisma.outOfOfficeEntry.upsert({
where: {
uuid: input.uuid ?? "",
userId: ctx.user.id,
},
create: {
uuid: uuidv4(),