Skip to main content

update

Function update 

Source
pub async fn update(
    pool: &PgPool,
    actor: &Actor,
    id: Uuid,
    upd: UserUpdate,
) -> AppResult<User>
Expand description

Updates a user (admin only). The role of OIDC users is managed through IdP groups and is overwritten at their next login.

§Invariants

  • Permission: administrator (403); an unknown user is “not found”.
  • Locks: the active administrators (FOR UPDATE, in id order), then the user’s row. At least one active administrator remains: demoting or deactivating the last one is refused (409), also when two administrators remove each other at once (tests/concurrency.rs). The role sync of a single-sign-on login (upsert_oidc_user) follows the IdP groups and is not held to this rule; teamcraft user create --role admin adds an administrator again.
  • Data: deactivating a user deletes all their sessions.
  • Audit: user.update.
  • Notifications / webhooks: none.
  • Atomic: one transaction.