MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / leaveOrg

Function leaveOrg

packages/web/src/features/userManagement/actions.ts:49–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47);
48
49export const leaveOrg = async (): Promise<{ success: boolean } | ServiceError> => sew(() =>
50 withAuth(async ({ user, org, prisma }) => {
51 const guardError = await _removeUserFromOrg(prisma, {
52 orgId: org.id,
53 userId: user.id,
54 lastOwnerMessage: "You are the last owner of this organization. Promote another member to owner before leaving.",
55 });
56
57 if (guardError) {
58 return guardError;
59 }
60
61 await createAudit({
62 action: "org.member_left",
63 actor: { id: user.id, type: "user" },
64 target: { id: user.id, type: "user" },
65 orgId: org.id,
66 metadata: {
67 message: `${user.id} left the organization`,
68 },
69 });
70
71 return {
72 success: true,
73 }
74 }));
75
76
77const _removeUserFromOrg = async (

Callers 1

MembersListFunction · 0.90

Calls 4

sewFunction · 0.90
withAuthFunction · 0.90
createAuditFunction · 0.90
_removeUserFromOrgFunction · 0.85

Tested by

no test coverage detected