-
Notifications
You must be signed in to change notification settings - Fork 11k
fix: Allow team admins to see hidden fields and UTM tracking data #23878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
160ed9d
9246448
59e0a20
5108192
0324525
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { shouldHideBrandingForEvent } from "@calcom/lib/hideBranding"; | |
| import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent"; | ||
| import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML"; | ||
| import { maybeGetBookingUidFromSeat } from "@calcom/lib/server/maybeGetBookingUidFromSeat"; | ||
| import { isTeamAdmin } from "@calcom/lib/server/queries/teams"; | ||
| import { BookingRepository } from "@calcom/lib/server/repository/booking"; | ||
| import prisma from "@calcom/prisma"; | ||
| import { customInputSchema } from "@calcom/prisma/zod-utils"; | ||
|
|
@@ -176,6 +177,14 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { | |
|
|
||
| const isLoggedInUserHost = checkIfUserIsHost(userId); | ||
|
|
||
| const isLoggedInUserTeamAdmin = !!( | ||
| userId && | ||
| ((eventType.team?.id && (await isTeamAdmin(userId, eventType.team.id))) || | ||
| (eventType.parent?.teamId && (await isTeamAdmin(userId, eventType.parent.teamId)))) | ||
| ); | ||
|
|
||
| const canViewHiddenData = isLoggedInUserHost || isLoggedInUserTeamAdmin; | ||
|
|
||
| if (bookingInfo !== null && eventType.seatsPerTimeSlot) { | ||
| await handleSeatsEventTypeOnBooking(eventType, bookingInfo, seatReferenceUid, isLoggedInUserHost); | ||
| } | ||
|
|
@@ -194,8 +203,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { | |
| }, | ||
| }); | ||
|
|
||
| if (!isLoggedInUserHost) { | ||
| // Removing hidden fields from responses | ||
| if (!canViewHiddenData) { | ||
| for (const key in bookingInfo.responses) { | ||
| const field = eventTypeRaw.bookingFields.find((field) => field.name === key); | ||
| if (field && !!field.hidden) { | ||
|
|
@@ -207,7 +215,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { | |
| const { currentOrgDomain } = orgDomainConfig(context.req); | ||
|
|
||
| async function getInternalNotePresets(teamId: number | null) { | ||
| if (!teamId || !isLoggedInUserHost) return []; | ||
| if (!teamId || !canViewHiddenData) return []; | ||
| return await prisma.internalNotePreset.findMany({ | ||
| where: { | ||
| teamId, | ||
|
|
@@ -256,6 +264,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { | |
| requiresLoginToUpdate, | ||
| rescheduledToUid, | ||
| isLoggedInUserHost, | ||
| canViewHiddenData, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 🧩 Analysis chainLGTM: Exposing canViewHiddenData in SSR props Matches server-side sanitization flow; just ensure all client UIs use this flag instead of isHost for hidden fields/UTMs. To double-check client usage: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Call sites of canViewHiddenData:"
rg -nP -C2 '\bcanViewHiddenData\b' --type=ts --type=tsx || true
echo
echo "Leftover UI gates using isLoggedInUserHost:"
rg -nP -C2 '\bisLoggedInUserHost\b' apps/web || trueLength of output: 2508 Use canViewHiddenData in client UI (replace isLoggedInUserHost) SSR now returns canViewHiddenData, but the client still reads props.isLoggedInUserHost — update UI gates to use props.canViewHiddenData for hidden fields/UTMs. Locations:
🤖 Prompt for AI Agents |
||
| internalNotePresets: internalNotes, | ||
| }, | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.