Update# clean up code from johannesst's PR

This commit is contained in:
Pellaeon Lin 2015-08-29 19:17:10 +08:00
parent 26d028bcdf
commit 69ff86ee53
2 changed files with 16 additions and 23 deletions

View File

@ -94,31 +94,25 @@ class RegisterController extends Controller {
} }
// FEATURE: allow only from specific email domain // allow only from specific email domain
$allowed_domains = $this->config->getAppValue($this->appName, 'allowed_domains', '');
$allowed_domains= $this->config->getAppValue($this->appName, 'allowed_domains',''); if ( $allowed_domains !== '' ) {
if ( ($allowed_domains === null) || ($allowed_domains === '') || ( strlen($allowed_domains)===0)){ $allowed_domains = explode(';', $allowed_domains);
}else{ $allowed = false;
$allowed_domains= explode (";",$allowed_domains); foreach ( $allowed_domains as $domain ) {
$allowed=false;
$domains=array();
foreach ($allowed_domains as $domain ) {
$domains[]=$domain;//=$domain.print_unescaped("<br>").$domains;
$maildomain=explode("@",$email)[1]; $maildomain=explode("@",$email)[1];
// valid domain, everythings fine // valid domain, everythings fine
if ($maildomain === $domain) { if ($maildomain === $domain) {
$allowed=true; $allowed=true;
break; break;
} }
} }
// $allowed still false->return error message
if ( $allowed === false ) { if ( $allowed === false ) {
return new TemplateResponse('registration', 'domains', ['domains' => return new TemplateResponse('registration', 'domains', ['domains' =>
$domains $domains
], 'guest'); ], 'guest');
} }
}//else var_dump($allowed_domains); }
return sendVerificationEmail($email); return sendVerificationEmail($email);
} }

View File

@ -3,13 +3,12 @@
?> ?>
<ul class="error-wide"> <ul class="error-wide">
<li class='error'><?php p($l->t('Registration is only allowed for following domains:')); ?> <li class='error'><?php p($l->t('Registration is only allowed for following domains:')); ?>
<?php <?php
foreach ($_['domains'] as $domain ){ foreach ($_['domains'] as $domain ){
echo "<p class='hint'>"; echo "<p class='hint'>";
p($domain); p($domain);
echo "</p>"; echo "</p>";
} }
?>
?> </li>
</li>
</ul> </ul>