* 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]>
22 lines
808 B
TypeScript
22 lines
808 B
TypeScript
import { TeamService } from "@calcom/lib/server/service/teamService";
|
|
|
|
import type {
|
|
IRemoveMemberService,
|
|
RemoveMemberContext,
|
|
RemoveMemberPermissionResult,
|
|
} from "./IRemoveMemberService";
|
|
|
|
/**
|
|
* Base abstract class for remove member services
|
|
* Provides common functionality and defines abstract methods for specific implementations
|
|
*/
|
|
export abstract class BaseRemoveMemberService implements IRemoveMemberService {
|
|
abstract checkRemovePermissions(context: RemoveMemberContext): Promise<RemoveMemberPermissionResult>;
|
|
|
|
abstract validateRemoval(context: RemoveMemberContext, hasPermission: boolean): Promise<void>;
|
|
|
|
async removeMembers(memberIds: number[], teamIds: number[], isOrg: boolean): Promise<void> {
|
|
await TeamService.removeMembers({ teamIds, userIds: memberIds, isOrg });
|
|
}
|
|
}
|