From 1daeaef1c5bd43b40f94f0b82545774caacc2c44 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Oct 2014 10:51:18 +0200 Subject: [PATCH] Fix that it is not possible to create an autologin auth backend Occured only when no database resource nor a ldap resource exists. --- .../Config/AuthenticationBackendConfigForm.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/application/forms/Config/AuthenticationBackendConfigForm.php b/application/forms/Config/AuthenticationBackendConfigForm.php index 8169b10f7..eecfb0891 100644 --- a/application/forms/Config/AuthenticationBackendConfigForm.php +++ b/application/forms/Config/AuthenticationBackendConfigForm.php @@ -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')); + } } }