Skip to main content

deactivate

Function deactivate 

Source
pub async fn deactivate(
    pool: &PgPool,
    actor: &Actor,
    user_id: Uuid,
    opts: &Offboarding,
) -> AppResult<DeactivationReport>
Expand description

Deactivates a user as an offboarding step.

§Invariants

  • Permission: administrator (403); an unknown user is “not found”; an administrator cannot offboard themselves (400).
  • Locks: the active administrators (FOR UPDATE, in id order, like users::update), then the user’s row, then what the hand-over moves. At least one active administrator remains (409).
  • Data: with a successor, the hand-over of ownership::hand_over plus the manager roles; without one, deactivating the only active manager of a group is refused (409) unless confirm_no_manager. With revoke_tokens the user’s API tokens are deleted. The account is deactivated and its sessions are deleted.
  • Audit: those of the hand-over, project.manager_handover per group, token.revoke_all with the count, user.update (inactive) and one user.offboard with the choices; the releases audit each revision (revision.checkout_forced_release).
  • Notifications / webhooks: those of the releases.
  • Atomic: one transaction for everything but the releases, which run afterwards, one transaction per revision (a refused one does not stop the others).