fix: org username check for dynamic and signup (#11390)
parent
7beb9568ba
commit
7154349e9e
|
@ -196,7 +196,6 @@ export default class SalesforceCalendarService implements Calendar {
|
|||
}
|
||||
|
||||
async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> {
|
||||
debugger;
|
||||
const contacts = await this.salesforceContactSearch(event);
|
||||
if (contacts.length) {
|
||||
if (contacts.length == event.attendees.length) {
|
||||
|
|
|
@ -9,7 +9,9 @@ export const validateUsername = async (username: string, email: string, organiza
|
|||
where: {
|
||||
...(organizationId ? { organizationId } : {}),
|
||||
OR: [
|
||||
{ username },
|
||||
// When inviting to org, invited user gets created with username now, so in an org context we
|
||||
// can't check for username as it will exist on signup
|
||||
...(!organizationId ? [{ username }] : [{}]),
|
||||
{
|
||||
AND: [
|
||||
{ email },
|
||||
|
|
|
@ -202,7 +202,11 @@ export async function getEventType(
|
|||
};
|
||||
}
|
||||
|
||||
export async function getDynamicEventType(input: TGetScheduleInputSchema) {
|
||||
export async function getDynamicEventType(
|
||||
input: TGetScheduleInputSchema,
|
||||
organizationDetails: { currentOrgDomain: string | null; isValidOrgDomain: boolean }
|
||||
) {
|
||||
const { currentOrgDomain, isValidOrgDomain } = organizationDetails;
|
||||
// For dynamic booking, we need to get and update user credentials, schedule and availability in the eventTypeObject as they're required in the new availability logic
|
||||
if (!input.eventTypeSlug) {
|
||||
throw new TRPCError({
|
||||
|
@ -220,6 +224,7 @@ export async function getDynamicEventType(input: TGetScheduleInputSchema) {
|
|||
? [input.usernameList]
|
||||
: [],
|
||||
},
|
||||
organization: isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null,
|
||||
},
|
||||
select: {
|
||||
allowDynamicBooking: true,
|
||||
|
@ -246,7 +251,9 @@ export function getRegularOrDynamicEventType(
|
|||
organizationDetails: { currentOrgDomain: string | null; isValidOrgDomain: boolean }
|
||||
) {
|
||||
const isDynamicBooking = input.usernameList && input.usernameList.length > 1;
|
||||
return isDynamicBooking ? getDynamicEventType(input) : getEventType(input, organizationDetails);
|
||||
return isDynamicBooking
|
||||
? getDynamicEventType(input, organizationDetails)
|
||||
: getEventType(input, organizationDetails);
|
||||
}
|
||||
|
||||
export async function getAvailableSlots({ input, ctx }: GetScheduleOptions) {
|
||||
|
|
Loading…
Reference in New Issue