fix(32.2): WR-05 hand the deactivate revocation the plain transaction

The deactivate lifecycle fired BackendAccessRevokedEvent with actionDB's Unscoped session, so a listener's Delete through ev.Tx was a hard delete only for that reason. It now passes the save's transaction like every other site.
This commit is contained in:
Jakub Zych
2026-11-21 09:21:59 +01:00
parent a261a8fdfe
commit 60bc6ee68f
3 changed files with 15 additions and 2 deletions

View File

@@ -288,7 +288,14 @@ func (c usersAdmin) lifecycles() []usersLifecycle {
Updates(map[string]any{"is_activated": false, "tokens_valid_after": revocationCutoff()}).Error; err != nil {
return err
}
if err := fireBackendAccessRevoked(ctx, c.application(), db, BackendAccessDeactivated, user.ID); err != nil {
// Listeners get the save's transaction itself, as at every
// other site, not db: that is an Unscoped session, on which
// a listener's Delete would be a hard delete.
tx, ok := TxFromContext(ctx)
if !ok {
return errors.New("cabana: administrators: an action needs its transaction")
}
if err := fireBackendAccessRevoked(ctx, c.application(), tx, BackendAccessDeactivated, user.ID); err != nil {
return err
}
// A deactivated administrator can no longer act anywhere,