mirror of https://github.com/MISP/MISP
new: [registration] fall back to the e-mail domain if no org info is provided
- also, make the org info optionalpull/5560/head
parent
70e1772bb0
commit
48cbfd7536
|
@ -2271,8 +2271,8 @@ class UsersController extends AppController
|
|||
$requestObject[$key] = trim($this->request->data[$key]);
|
||||
}
|
||||
}
|
||||
if (empty($requestObject['email']) || empty($requestObject['org_name'])) {
|
||||
throw new InvalidArgumentException(__('We require at least the email and org_name fields to be filled.'));
|
||||
if (empty($requestObject['email'])) {
|
||||
throw new InvalidArgumentException(__('We require at least the email field to be filled.'));
|
||||
}
|
||||
$this->loadModel('Inbox');
|
||||
$this->Inbox->create();
|
||||
|
|
|
@ -437,6 +437,9 @@ class Organisation extends AppModel
|
|||
$conditions = array('Organisation.uuid' => $registration['Inbox']['data']['org_uuid']);
|
||||
} else if (!empty($registration['Inbox']['data']['org_name'])) {
|
||||
$conditions = array('Organisation.name' => $registration['Inbox']['data']['org_name']);
|
||||
} else {
|
||||
$domain = explode('@', $registration['Inbox']['data']['email'])[1];
|
||||
$conditions = array('LOWER(Organisation.name)' => strtolower($domain));
|
||||
}
|
||||
$identifiedOrg = $this->User->Organisation->find('first', array(
|
||||
'recursive' => -1,
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
$suggestedOrgText = __('No preference');
|
||||
$suggestedRoleText = '';
|
||||
$domain = explode('@', $registration['Inbox']['data']['email'])[1];
|
||||
if ($suggestedOrg !== null) {
|
||||
if ($suggestedOrg === false) {
|
||||
$suggestedOrgText = '<br /> <span class="bold red">' . __('Conflicting requirements') . '</span>';
|
||||
} else if ($suggestedOrg === -1){
|
||||
$suggestedOrgText = sprintf(
|
||||
'<span class="red">%s%s</span>%s <a href="%s/admin/organisations/add%s%s" class="black fas fa-plus" title="%s"></a>',
|
||||
'<span class="red">%s%s%s</span>%s <a href="%s/admin/organisations/add%s%s%s" class="black fas fa-plus" title="%s"></a>',
|
||||
(empty($registration['Inbox']['data']['org_name']) && empty($registration['Inbox']['data']['org_uuid'])) ? h($domain) . ' ' : '',
|
||||
empty($registration['Inbox']['data']['org_name']) ? '' : h($registration['Inbox']['data']['org_name']) . ' ',
|
||||
empty($registration['Inbox']['data']['org_uuid']) ? '' : h($registration['Inbox']['data']['org_uuid']) . ' ',
|
||||
__('Requested organisation not found.'),
|
||||
$baseurl,
|
||||
(empty($registration['Inbox']['data']['org_name']) && empty($registration['Inbox']['data']['org_uuid'])) ? '/name:' . h($domain) : '',
|
||||
empty($registration['Inbox']['data']['org_name']) ? '' : '/name:' . h($registration['Inbox']['data']['org_name']),
|
||||
empty($registration['Inbox']['data']['org_uuid']) ? '' : '/uuid:' . h($registration['Inbox']['data']['org_uuid']),
|
||||
__('Create a new organisation')
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
),
|
||||
array(
|
||||
'field' => 'org_name',
|
||||
'label' => __('Your organisation\'s name'),
|
||||
'class' => 'input-xxlarge',
|
||||
'required' => 1
|
||||
'label' => __('Your organisation\'s name (optional)'),
|
||||
'class' => 'input-xxlarge'
|
||||
),
|
||||
array(
|
||||
'field' => 'org_uuid',
|
||||
|
|
Loading…
Reference in New Issue