Skip to main content

organization_join

Function organization_join 

Source
pub fn organization_join(
    bridge: &HostBridge,
    input: &str,
) -> Result<String, String>
Expand description

before_create on membership: work out who is being added.

The submitted body may name the person either way:

  • user_id — used as given,
  • email (whatever the app’s identity field is) — looked up here.

The lookup belongs on this side of the API. A member listing users only sees the people they already share an organisation with (see the user model’s read = "member"), so the person doing the adding cannot resolve an outsider’s address to an id — which is exactly who they are trying to add. Doing it in a hook keeps that asymmetry: the address is resolved for the one purpose it was given for, and nothing about the account comes back.

Rejects, rather than letting the insert fail later:

SituationStatus
neither user_id nor an identity422
no account with that identity404
already a member of this organisation409