* 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 }
)
| 60 | * swallow and log the error instead of rethrowing. |
| 61 | */ |
| 62 | async 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 | |
| 78 | async function getIsRegistrationAllowed(inviteId?: string | null) { |
| 79 | // ALLOW_REGISTRATION is always undefined in cloud |
no test coverage detected