Code for handling registrations for allowed and not allowed domains

This commit is contained in:
Johannes Starosta 2015-07-13 03:28:47 +02:00
parent 18b4911038
commit de6137e7ff
2 changed files with 39 additions and 1 deletions

View File

@ -94,7 +94,35 @@ class RegisterController extends Controller {
), 'error');
}
// FEATURE: allow only from specific email domain
$allowed_domains= $this->config->getAppValue($this->appName, 'allowed_domains','');
if ($allowed_domains !== null || $allowed_domains !== ''){
$allowed_domains= explode (";";$allowed_domains);
$allowed=false;
$domains='';
foreach ($allowed_domains as $domain ) {
$domains=$domain."\n".$domains;
$maildomain=explode("@",$email)[1];
// valid domain, everythings fine
if ($maildomain === $domain) {
$allowed_domains=true;
break;
}
}
// $allowed still false->return error message
if ( $allowed === false ) {
return new TemplateResponse('', 'error', array(
'errors' => array(array(
'error' => $this->l10n->t('Only following domain names are allowed:\n'),
'hint' => ''
))
), 'error');
}
}
$token = $this->pendingreg->save($email);
//TODO: check for error

View File

@ -48,7 +48,17 @@ class SettingsController extends Controller {
* @return DataResponse
*/
public function admin($registered_user_group, $allowed_domains) {
$this->config->setAppValue($this->appName, 'allowed_domains', $allowed_domains);
if ($allowed_domains===''){
$this->config->deleteAppValue($this->appName, 'registered_user_group');
}else{
/*
$new_domains='';
$domains=explode($allowed_domains,';');
foreach ( $domains as $domain) {
if( (strlen($domain)i >= 3) && (strpos($domain,'.'
}*/
$this->config->setAppValue($this->appName, 'allowed_domains', $allowed_domains);
}
$groups = $this->groupmanager->search('');
foreach ( $groups as $group ) {
$group_id_list[] = $group->getGid();