mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* Fallback to org admin * Prevent accidental privilege escalation as code changes in the future * When org admin, we don't actually need to do the db query * Use findMany and Map to drill down permission adjustments * Exclude .MEMBER from overriding role, we likely don't want to demote * refactor logic * Add tests for services/factories + removeHandler * fix type check --------- Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Sean Brydon <[email protected]>
32 lines
872 B
TypeScript
32 lines
872 B
TypeScript
import type { MembershipRole } from "@calcom/prisma/enums";
|
|
|
|
export interface RemoveMemberContext {
|
|
userId: number;
|
|
isOrgAdmin: boolean;
|
|
memberIds: number[];
|
|
teamIds: number[];
|
|
isOrg: boolean;
|
|
}
|
|
|
|
export interface RemoveMemberPermissionResult {
|
|
hasPermission: boolean;
|
|
userRoles?: Map<number, MembershipRole | null>;
|
|
}
|
|
|
|
export interface IRemoveMemberService {
|
|
/**
|
|
* Checks if the user has permission to remove members from teams
|
|
*/
|
|
checkRemovePermissions(context: RemoveMemberContext): Promise<RemoveMemberPermissionResult>;
|
|
|
|
/**
|
|
* Validates that the removal can proceed (e.g., owner checks)
|
|
*/
|
|
validateRemoval(context: RemoveMemberContext, hasPermission: boolean): Promise<void>;
|
|
|
|
/**
|
|
* Performs the actual removal of members from teams
|
|
*/
|
|
removeMembers(memberIds: number[], teamIds: number[], isOrg: boolean): Promise<void>;
|
|
}
|