fix(32.2): WR-04 never fire BackendAccessRevokedEvent without the save's transaction
fireBackendAccessRevoked refuses a nil tx before any listener runs, and the Administrators and Roles update hooks fail closed (like the delete hook) when the save carries no transaction, instead of firing with whatever TxFromContext answered.
This commit is contained in:
@@ -197,7 +197,12 @@ func (c rolesAdmin) FormAfterUpdate(ctx context.Context, model any) error {
|
||||
if err := db.Unscoped().Model(&BackendUser{}).Where("role_id = ?", role.ID).Pluck("id", &holders).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
tx, _ := TxFromContext(ctx)
|
||||
// writeDB proved the save carries its transaction; the event gets that
|
||||
// transaction itself, like every other site.
|
||||
tx, ok := TxFromContext(ctx)
|
||||
if !ok {
|
||||
return errors.New("cabana: roles: a save needs its transaction")
|
||||
}
|
||||
if err := fireBackendAccessRevoked(ctx, c.screens.application(), tx, BackendAccessPermissions, holders...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user