From 0fb6b8e4a5bd5964f1f9dcd443aa75dac1810f12 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:05:29 +0300 Subject: [PATCH 01/15] Issue #83: Add a test case. --- tests/features/ecas-register.feature | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/features/ecas-register.feature b/tests/features/ecas-register.feature index 95d0a753..995ad7d0 100644 --- a/tests/features/ecas-register.feature +++ b/tests/features/ecas-register.feature @@ -1,12 +1,22 @@ -@javascript @ecas-login +@api @javascript @ecas-login Feature: Register through OE Authentication In order to be able to have new users As an anonymous user of the system I need to be able to go to the registration URL + @DrupalLogin @BackupAuthConfigs @RebuildRouter Scenario: Register Given I am an anonymous user When I visit "the user registration page" # Redirected to the Ecas mockup server. And I click "External" Then I should see "Create an account" + + Given I am logged in as a user with the "administer authentication configuration" permission + When I am on "the Authentication configuration page" + And I uncheck "Redirect user registration route to EU Login" + Then I press "Save configuration" + + Given I am an anonymous user + When I visit "the user registration page" + Then I should see "Create new account" From 2e91cdfe930a7eda85ad89fd628dcf2ac22e8832 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:07:32 +0300 Subject: [PATCH 02/15] Issue #83: Provide a new boolean configuration. Default to TRUE. --- config/install/oe_authentication.settings.yml | 1 + config/schema/oe_authentication.schema.yml | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/install/oe_authentication.settings.yml b/config/install/oe_authentication.settings.yml index 024c03ac..5adb613f 100644 --- a/config/install/oe_authentication.settings.yml +++ b/config/install/oe_authentication.settings.yml @@ -3,3 +3,4 @@ register_path: 'eim/external/register.cgi' validation_path: 'TicketValidationService' assurance_level: TOP ticket_types: SERVICE,PROXY +redirect_user_register_route: true diff --git a/config/schema/oe_authentication.schema.yml b/config/schema/oe_authentication.schema.yml index 65dce025..1f47968b 100644 --- a/config/schema/oe_authentication.schema.yml +++ b/config/schema/oe_authentication.schema.yml @@ -16,4 +16,7 @@ oe_authentication.settings: label: 'Application assurance levels' ticket_types: type: string - label: 'Application available ticket types' \ No newline at end of file + label: 'Application available ticket types' + redirect_user_register_route: + type: boolean + label: 'Redirect Drupal user registration route to EU Login' From 0aa3928095ee57cc0463dc286205967c12405d22 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:08:53 +0300 Subject: [PATCH 03/15] Issue #83: Expose the new config in the UI. --- src/Form/AuthenticationSettingsForm.php | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index 1e70289e..3d16323b 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -4,8 +4,11 @@ namespace Drupal\oe_authentication\Form; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RouteBuilderInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Settings form for module. @@ -17,6 +20,36 @@ class AuthenticationSettingsForm extends ConfigFormBase { */ const CONFIG_NAME = 'oe_authentication.settings'; + /** + * The route builder service. + * + * @var \Drupal\Core\Routing\RouteBuilderInterface + */ + protected $routeBuilder; + + /** + * Constructs a new form instance. + * + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The factory for configuration objects. + * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder + * The route builder service. + */ + public function __construct(ConfigFactoryInterface $config_factory, RouteBuilderInterface $route_builder) { + parent::__construct($config_factory); + $this->routeBuilder = $route_builder; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('config.factory'), + $container->get('router.builder') + ); + } + /** * {@inheritdoc} */ @@ -53,6 +86,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#title' => $this->t('Application available ticket types'), '#default_value' => $this->config(static::CONFIG_NAME)->get('ticket_types'), ]; + $form['redirect_user_register_route'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Redirect user registration route to EU Login'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('redirect_user_register_route'), + ]; return parent::buildForm($form, $form_state); } @@ -60,14 +98,23 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { + $original_redirect_user_register_route = $this->config(static::CONFIG_NAME) + ->get('redirect_user_register_route'); + $this->config(static::CONFIG_NAME) ->set('protocol', $form_state->getValue('protocol')) ->set('register_path', $form_state->getValue('register_path')) ->set('validation_path', $form_state->getValue('validation_path')) ->set('assurance_level', $form_state->getValue('assurance_level')) ->set('ticket_types', $form_state->getValue('ticket_types')) + ->set('redirect_user_register_route', $form_state->getValue('redirect_user_register_route')) ->save(); parent::submitForm($form, $form_state); + + // Rebuild the routes if the redirect user register config has changed. + if ($original_redirect_user_register_route != $form_state->getValue('redirect_user_register_route')) { + $this->routeBuilder->rebuild(); + } } /** From 9f0c39dbb72f94882dc2a4236e1915f44f01b655 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:10:19 +0300 Subject: [PATCH 04/15] Issue #83: Make /user/register route aware of the new config. --- oe_authentication.services.yml | 3 ++- src/Routing/RouteSubscriber.php | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/oe_authentication.services.yml b/oe_authentication.services.yml index a003bb96..731e7d8c 100644 --- a/oe_authentication.services.yml +++ b/oe_authentication.services.yml @@ -5,7 +5,8 @@ services: tags: - { name: access_check, applies_to: _external_user_access_check } oe_authentication.route_subscriber: - class: \Drupal\oe_authentication\Routing\RouteSubscriber + class: Drupal\oe_authentication\Routing\RouteSubscriber + arguments: ['@config.factory'] tags: - { name: event_subscriber } oe_authentication.event_subscriber: diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index e36c5e5b..efaba90d 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -4,6 +4,7 @@ namespace Drupal\oe_authentication\Routing; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; @@ -13,6 +14,23 @@ */ class RouteSubscriber extends RouteSubscriberBase { + /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** + * Constructs a new route event subscriber. + * + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory service. + */ + public function __construct(ConfigFactoryInterface $config_factory) { + $this->configFactory = $config_factory; + } + /** * {@inheritdoc} */ @@ -33,12 +51,15 @@ protected function alterRoutes(RouteCollection $collection): void { } // Replace the core register route controller. - $route = $collection->get('user.register'); - if ($route instanceof Route) { - $defaults = $route->getDefaults(); - unset($defaults['_form']); - $defaults['_controller'] = '\Drupal\oe_authentication\Controller\RegisterController::register'; - $route->setDefaults($defaults); + $config = $this->configFactory->get('oe_authentication.settings'); + if ($config->get('redirect_user_register_route')) { + $route = $collection->get('user.register'); + if ($route instanceof Route) { + $defaults = $route->getDefaults(); + unset($defaults['_form']); + $defaults['_controller'] = '\Drupal\oe_authentication\Controller\RegisterController::register'; + $route->setDefaults($defaults); + } } // Replace the cas callback route controller. From fcebdcc37ae97ce51e4ee2ae456c952967515e14 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:11:17 +0300 Subject: [PATCH 05/15] Issue #83: The redirect response cache should be invalidated when the config is changing. --- src/Controller/RegisterController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controller/RegisterController.php b/src/Controller/RegisterController.php index cc03a2e0..40c61921 100644 --- a/src/Controller/RegisterController.php +++ b/src/Controller/RegisterController.php @@ -62,8 +62,9 @@ public function register(): TrustedRedirectResponse { $url = $this->getRegisterUrl()->toString(); $response = new TrustedRedirectResponse($url); - $cache = new CacheableMetadata(); - $cache->addCacheContexts(['user.roles:anonymous']); + $cache = (new CacheableMetadata()) + ->addCacheContexts(['user.roles:anonymous']) + ->setCacheTags(['config:oe_authentication.settings']); $response->addCacheableDependency($cache); return $response; From 415525ecc1405564d04f77d9d818b2eb87926676 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 17:12:05 +0300 Subject: [PATCH 06/15] Issue #83: After Behat config revert the router should be rebuild. --- tests/Behat/AuthenticationContext.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 83b694c9..08708f68 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -105,6 +105,27 @@ public function backupCasConfigs(): void { } } + /** + * Act after reverting the config. + * + * Some tests are changing the oe_authentication:redirect_user_register_route + * config value. Changing this value, requires router rebuilding. This is + * covered in UI, see AuthenticationSettingsForm::submitForm(). But, after + * running the tests, the oe_authentication configuration is reverted to its + * initial values, in ConfigContext::cleanConfig(). This time the UI is not + * used anymore, so we need to do it after the scenario. Note that the hooks + * of AuthenticationContext are always running after ConfigContext hooks, so + * the router rebuild will run after reverting the config. + * + * @see \Drupal\oe_authentication\Form\AuthenticationSettingsForm::submitForm() + * @see \Drupal\DrupalExtension\Context\ConfigContext::cleanConfig() + * + * @AfterScenario @RebuildRouter + */ + public function rebuildRoutes(): void { + \Drupal::service('router.builder')->rebuild(); + } + /** * Navigates to the current user's page. * From ec181355f4b904a9f9efcba668167bc67b6c6b8d Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 23:06:35 +0300 Subject: [PATCH 07/15] Issue #83: The feature makes no JavaScript testing. --- behat.yml.dist | 5 +++-- tests/features/ecas-register.feature | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index ed68dc12..043a72d6 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -16,8 +16,9 @@ default: user registration: '/user/register' extensions: Drupal\MinkExtension: - goutte: ~ - selenium2: ~ + goutte: + guzzle_parameters: + verify: false ajax_timeout: 10 browser_name: 'chrome' javascript_session: 'selenium2' diff --git a/tests/features/ecas-register.feature b/tests/features/ecas-register.feature index 995ad7d0..b15203b1 100644 --- a/tests/features/ecas-register.feature +++ b/tests/features/ecas-register.feature @@ -1,4 +1,4 @@ -@api @javascript @ecas-login +@api @ecas-login Feature: Register through OE Authentication In order to be able to have new users As an anonymous user of the system From 8e49cd852bcdf121707a64c7d8f7e6d944b283a5 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 23:29:19 +0300 Subject: [PATCH 08/15] Issue #83: Listen to ConfgEvents::SAVE to detect changes instead of form API. --- oe_authentication.services.yml | 5 ++ ...rRegisterRouteRedirectConfigSubscriber.php | 57 +++++++++++++++++++ src/Form/AuthenticationSettingsForm.php | 8 --- 3 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 src/Event/UserRegisterRouteRedirectConfigSubscriber.php diff --git a/oe_authentication.services.yml b/oe_authentication.services.yml index 731e7d8c..b336d382 100644 --- a/oe_authentication.services.yml +++ b/oe_authentication.services.yml @@ -14,3 +14,8 @@ services: tags: - { name: event_subscriber } arguments: ['@config.factory', '@messenger'] + oe_authentication.config_subscriber: + class: Drupal\oe_authentication\Event\UserRegisterRouteRedirectConfigSubscriber + arguments: ['@router.builder'] + tags: + - { name: event_subscriber } diff --git a/src/Event/UserRegisterRouteRedirectConfigSubscriber.php b/src/Event/UserRegisterRouteRedirectConfigSubscriber.php new file mode 100644 index 00000000..cb644c79 --- /dev/null +++ b/src/Event/UserRegisterRouteRedirectConfigSubscriber.php @@ -0,0 +1,57 @@ +routeBuilder = $route_builder; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents(): array { + return [ + ConfigEvents::SAVE => 'onConfigSave', + ]; + } + + /** + * Acts when oe_authentication.settings:redirect_user_register_route changes. + * + * @param \Drupal\Core\Config\ConfigCrudEvent $event + * The config CRUD event. + */ + public function onConfigSave(ConfigCrudEvent $event): void { + if ($event->getConfig()->getName() === 'oe_authentication.settings') { + if ($event->isChanged('redirect_user_register_route')) { + $this->routeBuilder->rebuild(); + } + } + } + +} diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index 3d16323b..219b616d 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -98,9 +98,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $original_redirect_user_register_route = $this->config(static::CONFIG_NAME) - ->get('redirect_user_register_route'); - $this->config(static::CONFIG_NAME) ->set('protocol', $form_state->getValue('protocol')) ->set('register_path', $form_state->getValue('register_path')) @@ -110,11 +107,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->set('redirect_user_register_route', $form_state->getValue('redirect_user_register_route')) ->save(); parent::submitForm($form, $form_state); - - // Rebuild the routes if the redirect user register config has changed. - if ($original_redirect_user_register_route != $form_state->getValue('redirect_user_register_route')) { - $this->routeBuilder->rebuild(); - } } /** From d3c26cf9a725052523f0281fb76e943b16df2ffd Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 4 Jun 2019 23:31:03 +0300 Subject: [PATCH 09/15] Issue #83: Explain why we need a router rebuild at the end of Scenario. --- tests/Behat/AuthenticationContext.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 08708f68..e78c56e4 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -4,7 +4,6 @@ namespace Drupal\Tests\oe_authentication\Behat; -use Drupal\DrupalExtension\Context\ConfigContext; use Drupal\user\Entity\User; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Drupal\DrupalExtension\Context\RawDrupalContext; @@ -110,14 +109,16 @@ public function backupCasConfigs(): void { * * Some tests are changing the oe_authentication:redirect_user_register_route * config value. Changing this value, requires router rebuilding. This is - * covered in UI, see AuthenticationSettingsForm::submitForm(). But, after - * running the tests, the oe_authentication configuration is reverted to its - * initial values, in ConfigContext::cleanConfig(). This time the UI is not - * used anymore, so we need to do it after the scenario. Note that the hooks - * of AuthenticationContext are always running after ConfigContext hooks, so - * the router rebuild will run after reverting the config. - * - * @see \Drupal\oe_authentication\Form\AuthenticationSettingsForm::submitForm() + * covered by UserRegisterRouteRedirectConfigSubscriber event subscriber. The + * subscriber detects if the value of redirect_user_register_route has been + * changed and rebuilds the routes. However, because Behat tests are running + * in a single request, often the static cache is not invalidated, resulting + * in a failure to detect the config value changes, when the configs are + * reverted, in ConfigContext::cleanConfig(). Thus, we're manually rebuilding + * the routes at the end of the scenario for tests that requesting it, by + * using the @RebuildRouter tag. + * + * @see \Drupal\oe_authentication\Event\UserRegisterRouteRedirectConfigSubscriber * @see \Drupal\DrupalExtension\Context\ConfigContext::cleanConfig() * * @AfterScenario @RebuildRouter From 2402e8b99ea3e1c504c38695f9025667f846676e Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 11:52:59 +0300 Subject: [PATCH 10/15] Issue #83: QA remark: Don't hardcode the cache tag. --- src/Controller/RegisterController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Controller/RegisterController.php b/src/Controller/RegisterController.php index 40c61921..37228b6f 100644 --- a/src/Controller/RegisterController.php +++ b/src/Controller/RegisterController.php @@ -62,12 +62,13 @@ public function register(): TrustedRedirectResponse { $url = $this->getRegisterUrl()->toString(); $response = new TrustedRedirectResponse($url); - $cache = (new CacheableMetadata()) - ->addCacheContexts(['user.roles:anonymous']) - ->setCacheTags(['config:oe_authentication.settings']); - $response->addCacheableDependency($cache); + $cache_metadata = (new CacheableMetadata()) + ->addCacheContexts(['user.roles:anonymous']); + $oe_auth_settings = $this->configFactory->get('oe_authentication.settings'); - return $response; + return $response + ->addCacheableDependency($cache_metadata) + ->addCacheableDependency($oe_auth_settings); } /** From 7b7f2e4232a140008a019bf0d1071c2f8a795c26 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 12:08:17 +0300 Subject: [PATCH 11/15] Issue #83: QA remark: Explain why router rebuild is needed. --- src/Event/UserRegisterRouteRedirectConfigSubscriber.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Event/UserRegisterRouteRedirectConfigSubscriber.php b/src/Event/UserRegisterRouteRedirectConfigSubscriber.php index cb644c79..ef66ee52 100644 --- a/src/Event/UserRegisterRouteRedirectConfigSubscriber.php +++ b/src/Event/UserRegisterRouteRedirectConfigSubscriber.php @@ -41,7 +41,12 @@ public static function getSubscribedEvents(): array { } /** - * Acts when oe_authentication.settings:redirect_user_register_route changes. + * Rebuilds route table on changing the user registration redirection. + * + * We need to rebuild the route table when an administrator changes the option + * to redirect the user registration form to EU Login. In normal operations + * the route table is only updated when the cache is being rebuilt, but the + * administrator expects this to take effect instantly. * * @param \Drupal\Core\Config\ConfigCrudEvent $event * The config CRUD event. From 51f96eb0f449bf07a540633cb060ed3184e77195 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 12:11:17 +0300 Subject: [PATCH 12/15] Issue #83: QA remark: Document the 'user.register' route conditional redirect. --- src/Routing/RouteSubscriber.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index efaba90d..a936e57d 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -50,7 +50,8 @@ protected function alterRoutes(RouteCollection $collection): void { } - // Replace the core register route controller. + // Switch the Drupal user register form with a redirect to the EU Login + // registration if this option is enabled in the module configuration. $config = $this->configFactory->get('oe_authentication.settings'); if ($config->get('redirect_user_register_route')) { $route = $collection->get('user.register'); From 36d7c108305e0fd64c5784af3d2c1b8c0a6f24ef Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 12:22:22 +0300 Subject: [PATCH 13/15] Issue #83: QA remark: Use UI to revert back the setting. --- tests/Behat/AuthenticationContext.php | 23 ----------------------- tests/features/ecas-register.feature | 7 ++++++- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index e78c56e4..969ae9fa 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -104,29 +104,6 @@ public function backupCasConfigs(): void { } } - /** - * Act after reverting the config. - * - * Some tests are changing the oe_authentication:redirect_user_register_route - * config value. Changing this value, requires router rebuilding. This is - * covered by UserRegisterRouteRedirectConfigSubscriber event subscriber. The - * subscriber detects if the value of redirect_user_register_route has been - * changed and rebuilds the routes. However, because Behat tests are running - * in a single request, often the static cache is not invalidated, resulting - * in a failure to detect the config value changes, when the configs are - * reverted, in ConfigContext::cleanConfig(). Thus, we're manually rebuilding - * the routes at the end of the scenario for tests that requesting it, by - * using the @RebuildRouter tag. - * - * @see \Drupal\oe_authentication\Event\UserRegisterRouteRedirectConfigSubscriber - * @see \Drupal\DrupalExtension\Context\ConfigContext::cleanConfig() - * - * @AfterScenario @RebuildRouter - */ - public function rebuildRoutes(): void { - \Drupal::service('router.builder')->rebuild(); - } - /** * Navigates to the current user's page. * diff --git a/tests/features/ecas-register.feature b/tests/features/ecas-register.feature index b15203b1..e050b80c 100644 --- a/tests/features/ecas-register.feature +++ b/tests/features/ecas-register.feature @@ -4,7 +4,7 @@ Feature: Register through OE Authentication As an anonymous user of the system I need to be able to go to the registration URL - @DrupalLogin @BackupAuthConfigs @RebuildRouter + @DrupalLogin Scenario: Register Given I am an anonymous user When I visit "the user registration page" @@ -20,3 +20,8 @@ Feature: Register through OE Authentication Given I am an anonymous user When I visit "the user registration page" Then I should see "Create new account" + + Given I am logged in as a user with the "administer authentication configuration" permission + When I am on "the Authentication configuration page" + And I check "Redirect user registration route to EU Login" + Then I press "Save configuration" From a3735699f2f526389ab969680d10d651a05e2b55 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 12:26:00 +0300 Subject: [PATCH 14/15] Issue #83: Remove unused service injection. --- src/Form/AuthenticationSettingsForm.php | 33 ------------------------- 1 file changed, 33 deletions(-) diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index 219b616d..e27b9611 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -4,11 +4,8 @@ namespace Drupal\oe_authentication\Form; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RouteBuilderInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Settings form for module. @@ -20,36 +17,6 @@ class AuthenticationSettingsForm extends ConfigFormBase { */ const CONFIG_NAME = 'oe_authentication.settings'; - /** - * The route builder service. - * - * @var \Drupal\Core\Routing\RouteBuilderInterface - */ - protected $routeBuilder; - - /** - * Constructs a new form instance. - * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The factory for configuration objects. - * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder - * The route builder service. - */ - public function __construct(ConfigFactoryInterface $config_factory, RouteBuilderInterface $route_builder) { - parent::__construct($config_factory); - $this->routeBuilder = $route_builder; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('config.factory'), - $container->get('router.builder') - ); - } - /** * {@inheritdoc} */ From c18c523e4d95369b7c01d4e668f9b4700da9d652 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Wed, 5 Jun 2019 17:14:53 +0300 Subject: [PATCH 15/15] Issue #83: QA remark: Add the new config for existing sites. --- oe_authentication.post_update.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 oe_authentication.post_update.php diff --git a/oe_authentication.post_update.php b/oe_authentication.post_update.php new file mode 100644 index 00000000..e1677167 --- /dev/null +++ b/oe_authentication.post_update.php @@ -0,0 +1,17 @@ +getEditable('oe_authentication.settings') + ->set('redirect_user_register_route', TRUE) + ->save(); +}