chg: [user:afterSave] Do not execute trigger for login and logout actions

pull/8530/head
Sami Mokaddem 2022-07-22 10:05:34 +02:00
parent c8528a7c59
commit 85ada91dde
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 17 additions and 9 deletions

View File

@ -299,15 +299,23 @@ class User extends AppModel
$kafkaTopic = $this->kafkaTopic('user');
$action = empty($created) ? 'edit' : 'add';
$user = $this->data;
$user_id = $action == 'add' ? 0 : $user['User']['id'];
$workflowErrors = [];
$logging = [
'model' => 'User',
'action' => $action,
'id' => $user_id,
'message' => __('Error while executing workflow.'),
];
$this->executeTrigger('user-after-save', $user['User'], $workflowErrors, $logging);
if (
empty($user['User']['action']) ||
(
$user['User']['action'] != 'logout' &&
$user['User']['action'] != 'login'
)
) {
$user_id = $action == 'add' ? 0 : $user['User']['id'];
$workflowErrors = [];
$logging = [
'model' => 'User',
'action' => $action,
'id' => $user_id,
'message' => __('Error while executing workflow.'),
];
$this->executeTrigger('user-after-save', $user['User'], $workflowErrors, $logging);
}
if ($pubToZmq || $kafkaTopic) {
if (!empty($this->data)) {
$user = $this->data;