mirror of https://github.com/MISP/MISP
fix: [internal] Email new login sending
parent
867d5281f0
commit
01c3a0329f
|
@ -659,21 +659,18 @@ class User extends AppModel
|
|||
public function getUserById($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new NotFoundException('Invalid user ID.');
|
||||
throw new InvalidArgumentException('Invalid user ID.');
|
||||
}
|
||||
return $this->find(
|
||||
'first',
|
||||
array(
|
||||
'conditions' => array('User.id' => $id),
|
||||
'recursive' => -1,
|
||||
'contain' => array(
|
||||
'Organisation',
|
||||
'Role',
|
||||
'Server',
|
||||
'UserSetting',
|
||||
)
|
||||
)
|
||||
);
|
||||
return $this->find('first', [
|
||||
'conditions' => ['User.id' => $id],
|
||||
'recursive' => -1,
|
||||
'contain' => [
|
||||
'Organisation',
|
||||
'Role',
|
||||
'Server',
|
||||
'UserSetting',
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -861,6 +858,10 @@ class User extends AppModel
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!isset($user['User'])) {
|
||||
throw new InvalidArgumentException("Invalid user model provided.");
|
||||
}
|
||||
|
||||
if ($user['User']['disabled'] || !$this->checkIfUserIsValid($user['User'])) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -260,13 +260,13 @@ class UserLoginProfile extends AppModel
|
|||
public function emailNewLogin(array $user)
|
||||
{
|
||||
if (!Configure::read('MISP.disable_emailing')) {
|
||||
$date_time = date('c');
|
||||
|
||||
$user = $this->User->getUserById($user['id']); // fetch in database format
|
||||
$datetime = date('c'); // ISO 8601 date
|
||||
$body = new SendEmailTemplate('userloginprofile_newlogin');
|
||||
$body->set('userLoginProfile', $this->User->UserLoginProfile->_getUserProfile());
|
||||
$body->set('baseurl', Configure::read('MISP.baseurl'));
|
||||
$body->set('misp_org', Configure::read('MISP.org'));
|
||||
$body->set('date_time', $date_time);
|
||||
$body->set('date_time', $datetime);
|
||||
// Fetch user that contains also PGP or S/MIME keys for e-mail encryption
|
||||
$this->User->sendEmail($user, $body, false, "[" . Configure::read('MISP.org') . " MISP] New sign in.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue