mirror of https://github.com/MISP/MISP
chg: [internal] Update role changes immediately
parent
b7eef315df
commit
cdf47d705e
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
App::uses('AppModel', 'Model');
|
||||
|
||||
/**
|
||||
* @property User $User
|
||||
*/
|
||||
class Role extends AppModel
|
||||
{
|
||||
public $validate = array(
|
||||
|
@ -232,6 +235,18 @@ class Role extends AppModel
|
|||
return true;
|
||||
}
|
||||
|
||||
public function afterSave($created, $options = array())
|
||||
{
|
||||
// After role change, update `date_modified` field for all user with this role to apply this change to already
|
||||
// logged users.
|
||||
if (!$created && !empty($this->data)) {
|
||||
$roleId = $this->data['Role']['id'];
|
||||
$this->User->updateAll(['date_modified' => time()], ['role_id' => $roleId]);
|
||||
}
|
||||
|
||||
parent::afterSave($created, $options);
|
||||
}
|
||||
|
||||
public function afterFind($results, $primary = false)
|
||||
{
|
||||
foreach ($results as $key => $val) {
|
||||
|
|
Loading…
Reference in New Issue