MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / consumeInviteForUser

Function consumeInviteForUser

packages/trpc/src/routers/auth.ts:62–76  ·  view source on GitHub ↗

* Best-effort consumption of an invite for a user that just authenticated. * Failures (expired/invalid invite) must not block the sign-in itself, so we * swallow and log the error instead of rethrowing.

(
  userId: string,
  inviteId: string,
  log: { error: (obj: unknown, msg?: string) => void }
)

Source from the content-addressed store, hash-verified

60 * swallow and log the error instead of rethrowing.
61 */
62async function consumeInviteForUser(
63 userId: string,
64 inviteId: string,
65 log: { error: (obj: unknown, msg?: string) => void }
66) {
67 try {
68 const user = await db.user.findUniqueOrThrow({ where: { id: userId } });
69 await connectUserToOrganization({ user, inviteId });
70 } catch (error) {
71 log.error(
72 { userId, inviteId, error },
73 'Failed to connect user to organization via invite'
74 );
75 }
76}
77
78async function getIsRegistrationAllowed(inviteId?: string | null) {
79 // ALLOW_REGISTRATION is always undefined in cloud

Callers 1

auth.tsFile · 0.85

Calls 2

errorMethod · 0.45

Tested by

no test coverage detected