From c1347618ac6990373b5391fdb578c526ff7d5382 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 10 Jul 2013 14:02:29 +0200 Subject: [PATCH] Fix #1240 : Remove authentication>auto-create>enabled parameter --- config/configuration.sample.yml | 1 - .../AuthenticationManagerServiceProvider.php | 4 +++- lib/classes/patch/3817.php | 10 +++++----- lib/conf.d/configuration.yml | 1 - .../Fixtures/configuration-setup.yml | 9 +++------ .../Configuration/Fixtures/configuration.yml | 9 +++------ .../Fixtures/configuration-debugger.yml | 1 - .../Fixtures/configuration-maintenance.yml | 1 - ...uthenticationManagerServiceProviderTest.php | 18 ++++++++---------- .../Version/Migration/Migration38Test.php | 1 - 10 files changed, 22 insertions(+), 33 deletions(-) diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index c638e5270f..3931c98b71 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -82,7 +82,6 @@ border-manager: mediatypes: [Audio, Document, Flash, Image, Video] authentication: auto-create: - enabled: false templates: { } captcha: enabled: true diff --git a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php index 6e5a74b454..9648ec7304 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php @@ -67,8 +67,10 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface } }, $authConf['auto-create']['templates'])); + + $enabled = $app['phraseanet.registry']->get('GV_autoregister') && $app['registration.enabled']; - return new AccountCreator($app['tokens'], $app['phraseanet.appbox'], $authConf['auto-create']['enabled'], $templates); + return new AccountCreator($app['tokens'], $app['phraseanet.appbox'], $enabled, $templates); }); $app['authentication.providers'] = $app->share(function (Application $app) { diff --git a/lib/classes/patch/3817.php b/lib/classes/patch/3817.php index 9a6571690f..5a9ea516b9 100644 --- a/lib/classes/patch/3817.php +++ b/lib/classes/patch/3817.php @@ -50,15 +50,15 @@ class patch_3817 implements patchInterface { $auth = $app['phraseanet.configuration']['authentication']; - if (!isset($auth['captcha'])) { - return true; - } - - if (isset($auth['captcha']['trials-before-failure'])) { + if (isset($auth['captcha']) && isset($auth['captcha']['trials-before-failure'])) { $auth['captcha']['trials-before-display'] = $auth['captcha']['trials-before-failure']; unset($auth['captcha']['trials-before-failure']); } + if (isset($auth['auto-create']) && isset($auth['auto-create']['enabled'])) { + unset($auth['auto-create']['enabled']); + } + $app['phraseanet.configuration']['authentication'] = $auth; return true; diff --git a/lib/conf.d/configuration.yml b/lib/conf.d/configuration.yml index 86031392aa..a825e3c461 100644 --- a/lib/conf.d/configuration.yml +++ b/lib/conf.d/configuration.yml @@ -85,7 +85,6 @@ border-manager: mediatypes: [Audio, Document, Flash, Image, Video] authentication: auto-create: - enabled: false templates: { } captcha: enabled: true diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration-setup.yml b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration-setup.yml index d2aec2af26..58c79f2194 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration-setup.yml +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration-setup.yml @@ -68,7 +68,6 @@ border-manager: mediatypes: [Audio, Document, Flash, Image, Video] authentication: auto-create: - enabled: false templates: { } captcha: enabled: true @@ -116,8 +115,6 @@ registration-fields: required: true xsendfile: enabled: false - type: '' - mapping: - - - directory: '' - mount-point: '' + type: nginx + mapping: [] +plugins: [] diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml index d2aec2af26..58c79f2194 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/Fixtures/configuration.yml @@ -68,7 +68,6 @@ border-manager: mediatypes: [Audio, Document, Flash, Image, Video] authentication: auto-create: - enabled: false templates: { } captcha: enabled: true @@ -116,8 +115,6 @@ registration-fields: required: true xsendfile: enabled: false - type: '' - mapping: - - - directory: '' - mount-point: '' + type: nginx + mapping: [] +plugins: [] diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-debugger.yml b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-debugger.yml index 8e96612e6f..cc2a01a159 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-debugger.yml +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-debugger.yml @@ -93,7 +93,6 @@ border-manager: - Video authentication: auto-create: - enabled: false templates: { } captcha: enabled: true diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-maintenance.yml b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-maintenance.yml index d759922465..777037aa2b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-maintenance.yml +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/Fixtures/configuration-maintenance.yml @@ -93,7 +93,6 @@ border-manager: - Video authentication: auto-create: - enabled: false templates: { } captcha: enabled: true diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php index 6814d4732a..af9dd08ef3 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php @@ -107,12 +107,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $app = new PhraseaApplication(); $app->register(new ConfigurationServiceProvider()); - $app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig(); + $conf = $app['phraseanet.configuration']->getConfig(); $conf['authentication']['auto-create'] = array( - 'enabled' => true, 'templates' => array(), ); - $app['phraseanet.configuration'] = $conf; + $app['phraseanet.configuration']->setConfig($conf); $app['authentication.providers.account-creator']; } @@ -139,11 +138,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase })); $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; - $app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig(); + $conf = $app['phraseanet.configuration']->getConfig(); $conf['authentication']['captcha'] = array( 'enabled' => true, ); - $app['phraseanet.configuration'] = $conf; + $app['phraseanet.configuration']->setConfig($conf); $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') ->disableOriginalConstructor() @@ -177,11 +176,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase })); $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; - $app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig(); + $conf = $app['phraseanet.configuration']->getConfig(); $conf['authentication']['captcha'] = array( 'enabled' => false, ); - $app['phraseanet.configuration'] = $conf; + $app['phraseanet.configuration']->setConfig($conf); $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') ->disableOriginalConstructor() @@ -203,15 +202,14 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $template2 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false); $template2->set_template(self::$DI['user']); - $app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig(); + $conf = $app['phraseanet.configuration']->getConfig(); $conf['authentication']['auto-create'] = array( - 'enabled' => true, 'templates' => array( $template1->get_id(), $template2->get_login() ) ); - $app['phraseanet.configuration'] = $conf; + $app['phraseanet.configuration']->setConfig($conf); $this->assertEquals(array($template1, $template2), $app['authentication.providers.account-creator']->getTemplates()); diff --git a/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php b/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php index 3343bff54d..f9f7ce4e7d 100644 --- a/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php +++ b/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php @@ -202,7 +202,6 @@ class Migration38Test extends AbstractSetupTester ), 'authentication' => array( 'auto-create' => array( - 'enabled' => false, 'templates' => array( ), ),