* added layouts for moving teams step * added admin section for org creation step * extended org creation to also move existing teams * wip * wip * wip * further changes * Add checkout for org in onboarding * Fix ts errors * Self review feedback * Self review addressed * Fix unit tests * Fix ts error * Seans feedback addressed * feat: fix correct accounts pending * fix: unit tests for new invite member permissions * tests: org admin onboarding tests for existing user * tests: Inital user self serve flow * chore: update teamAndUserFixture to create X amount of teams * chore: add testId to card actionButton * test: add test-Id to continue or checkout button * tests: add tests for migrating existing teams * feat: match new designs * fix: isAdminCheck * chore: fix pricing copy * fix: flacky tests * Fix tests? * More test fixes * Check all checkboxes * Fix type error * Fix failing test and typescript issues * Fix unpaid org allowing auto-add users * Add self-serve flag * Skip tests * Add adminReview option * Fixes * Add server checks for impersonation * Improved error * feat: extract - and disalow updating from org uset list if not reviewed --------- Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: sean-brydon <sean@cal.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
23 lines
885 B
TypeScript
23 lines
885 B
TypeScript
import { OrganizationRepository } from "@calcom/lib/server/repository/organization";
|
|
|
|
/**
|
|
* It assumes that a user can only impersonate the members of the organization he is logged in to.
|
|
* Note: Ensuring that one organization's member can't impersonate other organization's member isn't the job of this function
|
|
*/
|
|
export async function ensureOrganizationIsReviewed(loggedInUserOrgId: number | undefined) {
|
|
if (loggedInUserOrgId) {
|
|
const org = await OrganizationRepository.findByIdIncludeOrganizationSettings({
|
|
id: loggedInUserOrgId,
|
|
});
|
|
|
|
if (!org) {
|
|
throw new Error("Error-OrgNotFound: You do not have permission to do this.");
|
|
}
|
|
|
|
if (!org.organizationSettings?.isAdminReviewed) {
|
|
// If the org is not reviewed, we can't allow impersonation
|
|
throw new Error("Error-OrgNotReviewed: You do not have permission to do this.");
|
|
}
|
|
}
|
|
}
|