mirror of https://github.com/MISP/MISP
fix: [community access requests] fixed serveral issues, fixes #5194
- added missing view to preview the request - don't throw errors when possible, instead show what should have been sentpull/5198/head
parent
f5e4c4f1bf
commit
9b2916a4c0
|
@ -159,7 +159,10 @@ Thank you in advance!',
|
|||
$params['gpgkey'] = $community['pgp_key'];
|
||||
$params['body'] = $body;
|
||||
$params['subject'] = '[' . $community['name'] . '] Requesting MISP access';
|
||||
$params['mock'] = !empty($this->request->data['Server']['mock']);
|
||||
$params['mock'] = !empty($this->request->data['Server']['mock']) ? $this->request->data['Server']['mock'] : 0;
|
||||
if (!empty(Configure::read('MISP.disable_emailing'))) {
|
||||
$params['mock'] = 1;
|
||||
}
|
||||
$result = $this->User->sendEmailExternal($this->Auth->user(), $params);
|
||||
$message = $result ? __('Request sent.') : __('Something went wrong and the request could not be sent.');
|
||||
if ($this->_isRest()) {
|
||||
|
@ -176,6 +179,9 @@ Thank you in advance!',
|
|||
$this->redirect(array('controller' => 'communities', 'action' => 'view', $id));
|
||||
} elseif ($result) {
|
||||
$this->set('result', $result);
|
||||
if (empty($this->request->data['Server']['mock'])) {
|
||||
$this->Flash->error(__('The message could not be sent (either because e-mailing is disabled or because encryption is misconfigured), however, you can view the e-mail that would have been sent below. Feel free to send it manually.'));
|
||||
}
|
||||
$this->render('request_access_email');
|
||||
} else {
|
||||
$this->Flash->error($message);
|
||||
|
|
|
@ -723,11 +723,12 @@ class User extends AppModel
|
|||
$Email = new CakeEmail();
|
||||
$recipient = array('User' => array('email' => $params['to']));
|
||||
$failed = false;
|
||||
$mock = false;
|
||||
if (!empty($params['gpgkey'])) {
|
||||
$recipient['User']['gpgkey'] = $params['gpgkey'];
|
||||
$encryptionResult = $this->__encryptUsingGPG($Email, $params['body'], $params['subject'], $recipient);
|
||||
if (isset($encryptionResult['failed'])) {
|
||||
$failed = true;
|
||||
$mock = true;
|
||||
}
|
||||
if (isset($encryptionResult['failureReason'])) {
|
||||
$failureReason = $encryptionResult['failureReason'];
|
||||
|
@ -754,8 +755,7 @@ class User extends AppModel
|
|||
}
|
||||
}
|
||||
$Email->attachments($attachments);
|
||||
$mock = false;
|
||||
if (Configure::read('MISP.disable_emailing') || !empty($params['mock'])) {
|
||||
if (!empty(Configure::read('MISP.disable_emailing')) || !empty($params['mock'])) {
|
||||
$Email->transport('Debug');
|
||||
$mock = true;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@
|
|||
$this->element('/genericElements/Forms/clear') .
|
||||
$this->Form->input('mock', array(
|
||||
'label' => __('Generate e-mail for later use, but do not send it'),
|
||||
'type' => 'checkbox'
|
||||
'type' => 'checkbox',
|
||||
'disabled' => !empty(Configure::read('MISP.disable_emailing')),
|
||||
'checked' => !empty(Configure::read('MISP.disable_emailing'))
|
||||
))
|
||||
),
|
||||
$this->Form->button('Submit', array(
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<div class="communities view">
|
||||
<?php
|
||||
echo sprintf(
|
||||
'<h3>%s</h3><p>%s</p><b>%s</b><p>%s</p><b>%s</b><p>%s</p>',
|
||||
__('Email to send in order to request access'),
|
||||
empty($mock) ? __('Emailing is currently disabled on the instance, but we have generated the e-mail that would normally be sent out below.') :
|
||||
__('Please find a generated e-mail below that you can use to contact the community in question'),
|
||||
__('Headers:'),
|
||||
nl2br(h($result['headers'])),
|
||||
__('Message:'),
|
||||
nl2br(h($result['message']))
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'sync', 'menuItem' => 'view_email'));
|
||||
?>
|
Loading…
Reference in New Issue