Fix that it is not possible to create an autologin auth backend

Occured only when no database resource nor a ldap resource exists.
This commit is contained in:
Johannes Meyer 2014-10-15 10:51:18 +02:00
parent 00ffb34829
commit 1daeaef1c5
1 changed files with 11 additions and 6 deletions

View File

@ -40,8 +40,6 @@ class AuthenticationBackendConfigForm extends ConfigForm
* @param Config $resources The resource configuration
*
* @return self
*
* @throws ConfigurationError In case no resources are available for authentication
*/
public function setResourceConfig(Config $resourceConfig)
{
@ -50,10 +48,6 @@ class AuthenticationBackendConfigForm extends ConfigForm
$resources[strtolower($resource->type)][] = $name;
}
if (empty($resources)) {
throw new ConfigurationError(t('Could not find any resources for authentication'));
}
$this->resources = $resources;
return $this;
}
@ -252,6 +246,17 @@ class AuthenticationBackendConfigForm extends ConfigForm
$configValues['type'] = $configValues['backend'];
$configValues['name'] = $authBackend;
$this->populate($configValues);
} elseif (empty($this->resources)) {
$autologinBackends = array_filter(
$this->config->toArray(),
function ($authBackendCfg) {
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin';
}
);
if (false === empty($autologinBackends)) {
throw new ConfigurationError(t('Could not find any resources for authentication'));
}
}
}