feat: fire user.Deactivating from the admin deactivate action
- DeactivatingEvent and DeactivatingEventName in classes - FireDeactivatingEvent modelled on FireDeletingEvent - the deactivate bulk action runs DeactivateUsers unchanged, then fires the event per newly deactivated user in the action's transaction
This commit is contained in:
@@ -120,6 +120,16 @@ func FireDeletingEvent(ctx context.Context, app *backpack.App, user *models.User
|
||||
return app.Events.Fire(ctx, &classes.DeletingEvent{User: user, Tx: tx})
|
||||
}
|
||||
|
||||
// FireDeactivatingEvent fires classes.DeactivatingEvent (user.Deactivating)
|
||||
// for user inside the deactivation transaction and returns the listeners'
|
||||
// error, so a failed listener rolls the deactivation back.
|
||||
func FireDeactivatingEvent(ctx context.Context, app *backpack.App, user *models.User, tx *gorm.DB) error {
|
||||
if app == nil || app.Events == nil {
|
||||
return nil
|
||||
}
|
||||
return app.Events.Fire(ctx, &classes.DeactivatingEvent{User: user, Tx: tx})
|
||||
}
|
||||
|
||||
// IssueToken mints the session JWT for user exactly as /register and
|
||||
// /login do: the plugin's JWT secret, golem15.user.jwt.ttl and the request
|
||||
// URL as the issuer.
|
||||
|
||||
Reference in New Issue
Block a user