fix: Organization Migration - Prevent the redirected username from being claimed by others. (#13675)
* Check for migrated username * Add e2e for reserved username due to migration * Add username change test * Update username.ts * fixed type checks * Refactor to use isOrganization * Typing * Typing * Removed the isOrganization function --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
18 files changed
+216
-45
No files matched your search
@@ -3,7 +3,6 @@ import { orderBy } from "lodash";
|
||||
|
||||
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { isOrganization } from "@calcom/lib/entityPermissionUtils";
|
||||
import { getOrgAvatarUrl, getTeamAvatarUrl, getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
|
||||
@@ -214,7 +213,7 @@ export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) =>
|
||||
await Promise.all(
|
||||
memberships
|
||||
.filter((mmship) => {
|
||||
if (isOrganization({ team: mmship.team })) {
|
||||
if (mmship.team.isOrganization) {
|
||||
return false;
|
||||
} else {
|
||||
if (!input?.filters || !hasFilter(input?.filters)) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { createAProfileForAnExistingUser } from "@calcom/lib/createAProfileForAnExistingUser";
|
||||
import { isOrganization } from "@calcom/lib/entityPermissionUtils";
|
||||
import { updateNewTeamMemberEventTypes } from "@calcom/lib/server/queries";
|
||||
import { closeComUpsertTeamUser } from "@calcom/lib/sync/SyncServiceManager";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
@@ -45,9 +44,8 @@ export const acceptOrLeaveHandler = async ({ ctx, input }: AcceptOrLeaveOptions)
|
||||
});
|
||||
}
|
||||
|
||||
const isAnOrganization = isOrganization({ team });
|
||||
const isASubteam = team.parentId !== null;
|
||||
const idOfOrganizationInContext = isAnOrganization ? team.id : isASubteam ? team.parentId : null;
|
||||
const idOfOrganizationInContext = team.isOrganization ? team.id : isASubteam ? team.parentId : null;
|
||||
const needProfileUpdate = !!idOfOrganizationInContext;
|
||||
if (needProfileUpdate) {
|
||||
await createAProfileForAnExistingUser({
|
||||
|
||||
@@ -2,7 +2,6 @@ import { updateQuantitySubscriptionFromStripe } from "@calcom/features/ee/teams/
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { IS_TEAM_BILLING_ENABLED } from "@calcom/lib/constants";
|
||||
import { createAProfileForAnExistingUser } from "@calcom/lib/createAProfileForAnExistingUser";
|
||||
import { isOrganization } from "@calcom/lib/entityPermissionUtils";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
@@ -174,7 +173,7 @@ async function handleExistingUsersInvites({
|
||||
}
|
||||
|
||||
const translation = await getTranslation(input.language ?? "en", "common");
|
||||
if (!isOrganization({ team })) {
|
||||
if (!team.isOrganization) {
|
||||
const [autoJoinUsers, regularUsers] = groupUsersByJoinability({
|
||||
existingUsersWithMembersips,
|
||||
team,
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { TFunction } from "next-i18next";
|
||||
|
||||
import { sendTeamInviteEmail } from "@calcom/emails";
|
||||
import { ENABLE_PROFILE_SWITCHER, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { isOrganization } from "@calcom/lib/entityPermissionUtils";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { isTeamAdmin } from "@calcom/lib/server/queries";
|
||||
@@ -452,7 +451,7 @@ export function getAutoJoinStatus({
|
||||
invitee: UserWithMembership;
|
||||
connectionInfoMap: Record<string, ReturnType<typeof getOrgConnectionInfo>>;
|
||||
}) {
|
||||
const isRegularTeam = !isOrganization({ team }) && !team.parentId;
|
||||
const isRegularTeam = !team.isOrganization && !team.parentId;
|
||||
|
||||
if (isRegularTeam) {
|
||||
// There are no-auto join in regular teams ever
|
||||
|
||||
Reference in new issue
Block a user