fix: Allow all team members to view hidden fields and UTM tracking data (#24619)
* Allow team admins to see hidden fields and UTM tracking data - Add team admin permission check for booking data visibility - Team admins can now view hidden booking field answers - Team admins can now view UTM tracking parameters - Support for managed events (parent team admins can view child event data) - Maintain backward compatibility with existing host permissions Fixes team admin access to booking details as requested in issue. * feat: allow all team members to view hidden fields and UTM data Previously only team admins could view hidden booking field answers and UTM tracking parameters. Now all team members can see this data, providing better transparency within teams. - Changed from isTeamAdmin to isTeamMember check - Team members (not just admins) can now view hidden booking fields - Team members can now view UTM tracking parameters - Maintains host permission (organizers can still see everything) - Supports managed events (parent team members can view child event data) * Address reviewer feedback: use existing membership pattern - Remove custom checkIfUserIsTeamAdmin function - Use existing userId_teamId pattern with prisma.membership.findUnique - Revert PrismaPlugin and variable name changes - Maintain same functionality with cleaner implementation * fix: use existing isTeamAdmin function and remove unnecessary UI changes * fix: Allow all team members to see hidden fields instead of just admins - Replace isTeamAdmin with isTeamMember in booking view permissions - Rename isLoggedInUserTeamAdmin to isLoggedInUserTeamMember for clarity - All team members can now view hidden fields and UTM tracking data Addresses feedback from @hariombalhara to allow all team members (not just admins) to see hidden booking data. Co-Authored-By: [email protected] <[email protected]> * fix: Correct import path for isTeamMember function - Change import from non-existent @calcom/lib/server/queries/teams - Use correct path @calcom/features/ee/teams/lib/queries - Fixes type check error: Cannot find module Co-Authored-By: [email protected] <[email protected]> * refactor: Optimize isTeamMember check to call function only once - Extract teamId using nullish coalescing operator - Single isTeamMember call instead of two - Cleaner and more efficient logic Co-Authored-By: [email protected] <[email protected]> * simplify --------- Co-authored-by: naaa760 <[email protected]> Co-authored-by: neha <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
7 files changed
+37
-27
No files matched your search
@@ -202,7 +202,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
||||
id="locationInput"
|
||||
placeholder={t(eventLocationType.organizerInputPlaceholder || "")}
|
||||
required
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
|
||||
defaultValue={
|
||||
defaultLocation ? defaultLocation[eventLocationType.defaultValueVariable] : undefined
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { orgDomainConfig } from "@calcom/ee/organizations/lib/orgDomains";
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
|
||||
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
|
||||
import { isTeamMember } from "@calcom/features/ee/teams/lib/queries";
|
||||
import { getDefaultEvent } from "@calcom/features/eventtypes/lib/defaultEvents";
|
||||
import { getBrandingForEventType } from "@calcom/features/profile/lib/getBranding";
|
||||
import { shouldHideBrandingForEvent } from "@calcom/features/profile/lib/hideBranding";
|
||||
@@ -183,6 +184,10 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
};
|
||||
|
||||
const isLoggedInUserHost = checkIfUserIsHost(userId);
|
||||
const eventTeamId = eventType.team?.id ?? eventType.parent?.teamId;
|
||||
const isLoggedInUserTeamMember = !!(userId && eventTeamId && (await isTeamMember(userId, eventTeamId)));
|
||||
|
||||
const canViewHiddenData = isLoggedInUserHost || isLoggedInUserTeamMember;
|
||||
|
||||
if (bookingInfo !== null && eventType.seatsPerTimeSlot) {
|
||||
await handleSeatsEventTypeOnBooking(eventType, bookingInfo, seatReferenceUid, isLoggedInUserHost);
|
||||
@@ -202,8 +207,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) {
|
||||
@@ -215,7 +219,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,
|
||||
@@ -233,8 +237,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
// Filter out organizer information if hideOrganizerEmail is true
|
||||
const sanitizedPreviousBooking =
|
||||
eventType.hideOrganizerEmail &&
|
||||
previousBooking &&
|
||||
previousBooking.rescheduledBy === bookingInfo.user?.email
|
||||
previousBooking &&
|
||||
previousBooking.rescheduledBy === bookingInfo.user?.email
|
||||
? { ...previousBooking, rescheduledBy: bookingInfo.user?.name }
|
||||
: previousBooking;
|
||||
|
||||
@@ -247,11 +251,11 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
hideBranding: isPlatformBooking
|
||||
? true
|
||||
: await shouldHideBrandingForEvent({
|
||||
eventTypeId: eventType.id,
|
||||
team: eventType?.parent?.team ?? eventType?.team,
|
||||
owner: eventType.users[0] ?? null,
|
||||
organizationId: session?.user?.profile?.organizationId ?? session?.user?.org?.id ?? null,
|
||||
}),
|
||||
eventTypeId: eventType.id,
|
||||
team: eventType?.parent?.team ?? eventType?.team,
|
||||
owner: eventType.users[0] ?? null,
|
||||
organizationId: session?.user?.profile?.organizationId ?? session?.user?.org?.id ?? null,
|
||||
}),
|
||||
profile,
|
||||
eventType,
|
||||
recurringBookings: await getRecurringBookings(bookingInfo.recurringEventId),
|
||||
@@ -264,6 +268,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
requiresLoginToUpdate,
|
||||
rescheduledToUid,
|
||||
isLoggedInUserHost,
|
||||
canViewHiddenData,
|
||||
internalNotePresets: internalNotes,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -100,7 +100,14 @@ export default function Success(props: PageProps) {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useCompatSearchParams();
|
||||
|
||||
const { eventType, bookingInfo, previousBooking, requiresLoginToUpdate, rescheduledToUid } = props;
|
||||
const {
|
||||
eventType,
|
||||
bookingInfo,
|
||||
previousBooking,
|
||||
requiresLoginToUpdate,
|
||||
rescheduledToUid,
|
||||
canViewHiddenData,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
allRemainingBookings,
|
||||
@@ -381,7 +388,6 @@ export default function Success(props: PageProps) {
|
||||
const isRescheduled = bookingInfo?.rescheduled;
|
||||
|
||||
const canCancelOrReschedule = !eventType?.disableCancelling || !eventType?.disableRescheduling;
|
||||
const _canCancelAndReschedule = !eventType?.disableCancelling && !eventType?.disableRescheduling;
|
||||
|
||||
const canCancel = !eventType?.disableCancelling;
|
||||
const canReschedule = !eventType?.disableRescheduling;
|
||||
@@ -715,7 +721,7 @@ export default function Success(props: PageProps) {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{!!utmParams && isHost && (
|
||||
{!!utmParams && canViewHiddenData && (
|
||||
<>
|
||||
<div className="mt-9 pr-2 font-medium sm:pr-0">{t("utm_params")}</div>
|
||||
<div className="col-span-2 mb-2 ml-3 mt-9 sm:ml-0">
|
||||
@@ -737,7 +743,7 @@ export default function Success(props: PageProps) {
|
||||
{showUtmParams && (
|
||||
<div className="col-span-2 mb-2 mt-2">
|
||||
{Object.entries(utmParams).filter(([_, value]) => Boolean(value)).length >
|
||||
0 ? (
|
||||
0 ? (
|
||||
<ul className="list-disc space-y-1 p-1 pl-5 sm:w-80">
|
||||
{Object.entries(utmParams)
|
||||
.filter(([_, value]) => Boolean(value))
|
||||
@@ -845,11 +851,10 @@ export default function Success(props: PageProps) {
|
||||
<span className="text-default inline">
|
||||
<span className="underline" data-testid="reschedule-link">
|
||||
<Link
|
||||
href={`/reschedule/${seatReferenceUid || bookingInfo?.uid}${
|
||||
currentUserEmail
|
||||
? `?rescheduledBy=${encodeURIComponent(currentUserEmail)}`
|
||||
: ""
|
||||
}`}
|
||||
href={`/reschedule/${seatReferenceUid || bookingInfo?.uid}${currentUserEmail
|
||||
? `?rescheduledBy=${encodeURIComponent(currentUserEmail)}`
|
||||
: ""
|
||||
}`}
|
||||
legacyBehavior>
|
||||
{t("reschedule")}
|
||||
</Link>
|
||||
|
||||
@@ -312,7 +312,7 @@ export const privacyFilteredLocations = (locations: LocationObject[]): PrivacyFi
|
||||
if (location.displayLocationPublicly || !eventLocationType) {
|
||||
return location;
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
const { address: _1, link: _2, hostPhoneNumber: _3, ...privacyFilteredLocation } = location;
|
||||
logger.debug("Applied Privacy Filter", location, privacyFilteredLocation);
|
||||
return privacyFilteredLocation;
|
||||
|
||||
@@ -113,7 +113,7 @@ export default class Office365CalendarService implements Calendar {
|
||||
invalidateTokenObject: () => oAuthManagerHelper.invalidateCredential(credential.id),
|
||||
expireAccessToken: () => oAuthManagerHelper.markTokenAsExpired(credential),
|
||||
updateTokenObject: (tokenObject) => {
|
||||
if (!Boolean(credential.delegatedTo)) {
|
||||
if (!credential.delegatedTo) {
|
||||
return oAuthManagerHelper.updateTokenObject({ tokenObject, credentialId: credential.id });
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
||||
@@ -21,19 +21,19 @@ export const createPhoneCallSchema = requiredFields.merge(
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => {
|
||||
return !!val ? val : undefined;
|
||||
return val ? val : undefined;
|
||||
}),
|
||||
guestEmail: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => {
|
||||
return !!val ? val : undefined;
|
||||
return val ? val : undefined;
|
||||
}),
|
||||
guestCompany: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => {
|
||||
return !!val ? val : undefined;
|
||||
return val ? val : undefined;
|
||||
}),
|
||||
beginMessage: z.string().optional(),
|
||||
generalPrompt: z.string().optional(),
|
||||
|
||||
@@ -263,9 +263,9 @@ export abstract class BaseOnboardingService implements IOrganizationOnboardingSe
|
||||
logoUrl?: string | null;
|
||||
bannerUrl?: string | null;
|
||||
}> {
|
||||
const uploadedLogoUrl = !!logoUrl ? await this.uploadImageAsset({ image: logoUrl, teamId: organizationId }) : logoUrl;
|
||||
const uploadedLogoUrl = logoUrl ? await this.uploadImageAsset({ image: logoUrl, teamId: organizationId }) : logoUrl;
|
||||
|
||||
const uploadedBannerUrl = !!bannerUrl
|
||||
const uploadedBannerUrl = bannerUrl
|
||||
? await this.uploadImageAsset({ image: bannerUrl, teamId: organizationId, isBanner: true })
|
||||
: bannerUrl;
|
||||
|
||||
|
||||
Reference in new issue
Block a user