fix: can't edit ooo (#18020)
* fix: can't edit ooo * fix: unauthorized users can edit ooo
This commit is contained in:
@@ -2453,6 +2453,7 @@
|
||||
"start_date_must_be_before_end_date": "Start date must be before end date",
|
||||
"start_date_must_be_in_the_future": "Start date must be in the future",
|
||||
"user_not_found": "User not found",
|
||||
"cannot_redirect_to_self": "Cannot redirect to self",
|
||||
"out_of_office_entry_already_exists": "Out of office entry already exists",
|
||||
"out_of_office_id_required": "Out of office entry id required",
|
||||
"booking_redirect_infinite_not_allowed": "There is already a booking redirect from that user to you.",
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user