fix: resolve permission issues (#3029)

This commit is contained in:
David Nguyen
2026-06-26 14:46:30 +10:00
committed by GitHub
parent 241929bb97
commit 96ab78c33f
5 changed files with 447 additions and 7 deletions
@@ -51,6 +51,14 @@ export const leaveOrganisationRoute = authenticatedProcedure
throw new AppError(AppErrorCode.NOT_FOUND);
}
// The organisation owner cannot leave their own organisation. Ownership must
// be transferred to another member first.
if (organisation.ownerUserId === userId) {
throw new AppError(AppErrorCode.UNAUTHORIZED, {
message: 'You cannot leave an organisation you own. Please transfer ownership first.',
});
}
const { organisationClaim } = organisation;
const inviteCount = organisation.invites.length;