(
target: TargetShape,
admin: Identity,
member: Identity,
options: { readonly roleSlug?: string } = {},
)
| 121 | * and both the session and the selector point at the later one. |
| 122 | */ |
| 123 | export const joinOrg = ( |
| 124 | target: TargetShape, |
| 125 | admin: Identity, |
| 126 | member: Identity, |
| 127 | options: { readonly roleSlug?: string } = {}, |
| 128 | ): Effect.Effect<Identity> => |
| 129 | Effect.gen(function* () { |
| 130 | const inviteResponse = yield* postJson(target, "/api/account/members/invite", admin, { |
| 131 | email: member.credentials?.email, |
| 132 | ...(options.roleSlug === undefined ? {} : { roleSlug: options.roleSlug }), |
| 133 | }); |
| 134 | const invitation = (yield* Effect.promise(() => inviteResponse.json())) as { id: string }; |
| 135 | const acceptResponse = yield* postJson(target, "/api/auth/accept-invitation", member, { |
| 136 | invitationId: invitation.id, |
| 137 | }); |
| 138 | return withRefreshedSession(member, acceptResponse, orgSelectorOf(admin)); |
| 139 | }); |
| 140 | |
| 141 | /** Create another org for this account; returns the identity bound to it. */ |
| 142 | export const createOrg = ( |
no test coverage detected