new: [registration] fall back to the e-mail domain if no org info is provided

- also, make the org info optional
pull/5560/head
iglocska 2020-04-07 22:46:35 +02:00
parent 70e1772bb0
commit 48cbfd7536
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
4 changed files with 11 additions and 6 deletions

View File

@ -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();

View File

@ -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,

View File

@ -1,16 +1,19 @@
<?php
$suggestedOrgText = __('No preference');
$suggestedRoleText = '';
$domain = explode('@', $registration['Inbox']['data']['email'])[1];
if ($suggestedOrg !== null) {
if ($suggestedOrg === false) {
$suggestedOrgText = '<br />&nbsp;&nbsp;<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')

View File

@ -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',