diff --git a/app/config/config.yml b/app/config/config.yml index 254344e7c..8ac0e3d54 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -41,6 +41,8 @@ twig: form_themes: - "LexikFormFilterBundle:Form:form_div_layout.html.twig" exception_controller: wallabag_core.exception_controller:showAction + globals: + registration_enabled: '%fosuser_registration%' # Doctrine Configuration doctrine: diff --git a/app/config/routing.yml b/app/config/routing.yml index 4fff4cb62..d4defca02 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -41,18 +41,6 @@ homepage: fos_user: resource: "@FOSUserBundle/Resources/config/routing/all.xml" -fos_user_security_login: - path: /login - defaults: - _controller: Wallabag\UserBundle\Controller\SecurityController::loginAction - methods: [GET, POST] - -fos_user_registration_register: - path: /register - defaults: - _controller: Wallabag\UserBundle\Controller\RegistrationController::registerAction - methods: [GET, POST] - fos_oauth_server_token: resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml" diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml index 6f5315b98..6ceeab15d 100644 --- a/app/config/wallabag.yml +++ b/app/config/wallabag.yml @@ -178,9 +178,6 @@ wallabag_core: - rule: _all ~ "https?://www\.lemonde\.fr/tiny.*" -wallabag_user: - registration_enabled: "%fosuser_registration%" - wallabag_import: allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain', 'text/csv'] resource_dir: "%kernel.project_dir%/web/uploads/import" diff --git a/composer.json b/composer.json index 5916ef81c..b49b21efa 100644 --- a/composer.json +++ b/composer.json @@ -68,7 +68,7 @@ "friendsofsymfony/jsrouting-bundle": "^2.2", "friendsofsymfony/oauth-server-bundle": "^1.5", "friendsofsymfony/rest-bundle": "~2.1", - "friendsofsymfony/user-bundle": "2.0.*", + "friendsofsymfony/user-bundle": "2.1.*", "guzzlehttp/guzzle": "^5.3.1", "guzzlehttp/psr7": "^1.8", "html2text/html2text": "^4.1", diff --git a/composer.lock b/composer.lock index 450c61a5c..06d1d3b96 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e054b16ab0878815e7b6f087e6cbd299", + "content-hash": "048e7bf2bc2fd50d898371035c5055a2", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -2504,26 +2504,27 @@ }, { "name": "friendsofsymfony/user-bundle", - "version": "v2.0.2", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git", - "reference": "2fc8a023d7ab482321cf7ec810ed49eab40eb50f" + "reference": "1049935edd24ec305cc6cfde1875372fa9600446" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/2fc8a023d7ab482321cf7ec810ed49eab40eb50f", - "reference": "2fc8a023d7ab482321cf7ec810ed49eab40eb50f", + "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/1049935edd24ec305cc6cfde1875372fa9600446", + "reference": "1049935edd24ec305cc6cfde1875372fa9600446", "shasum": "" }, "require": { "paragonie/random_compat": "^1 || ^2", "php": "^5.5.9 || ^7.0", - "symfony/form": "^2.7 || ^3.0", - "symfony/framework-bundle": "^2.7 || ^3.0", - "symfony/security-bundle": "^2.7 || ^3.0", - "symfony/templating": "^2.7 || ^3.0", - "symfony/twig-bundle": "^2.7 || ^3.0", + "symfony/form": "^2.8 || ^3.0 || ^4.0", + "symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0", + "symfony/security-bundle": "^2.8 || ^3.0 || ^4.0", + "symfony/templating": "^2.8 || ^3.0 || ^4.0", + "symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0", + "symfony/validator": "^2.8 || ^3.0 || ^4.0", "twig/twig": "^1.28 || ^2.0" }, "conflict": { @@ -2532,18 +2533,17 @@ }, "require-dev": { "doctrine/doctrine-bundle": "^1.3", - "friendsofphp/php-cs-fixer": "^1.11", - "phpunit/phpunit": "~4.8|~5.0", + "friendsofphp/php-cs-fixer": "^2.2", + "phpunit/phpunit": "^4.8.35|^5.7.11|^6.5", "swiftmailer/swiftmailer": "^4.3 || ^5.0 || ^6.0", - "symfony/console": "^2.7 || ^3.0", - "symfony/phpunit-bridge": "^2.7 || ^3.0", - "symfony/validator": "^2.7 || ^3.0", - "symfony/yaml": "^2.7 || ^3.0" + "symfony/console": "^2.8 || ^3.0 || ^4.0", + "symfony/phpunit-bridge": "^2.8 || ^3.0 || ^4.0", + "symfony/yaml": "^2.8 || ^3.0 || ^4.0" }, "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.1.x-dev" } }, "autoload": { @@ -2568,8 +2568,7 @@ "homepage": "https://github.com/friendsofsymfony/FOSUserBundle/contributors" }, { - "name": "Thibault Duplessis", - "email": "thibault.duplessis@gmail.com" + "name": "Thibault Duplessis" } ], "description": "Symfony FOSUserBundle", @@ -2580,9 +2579,9 @@ "support": { "docs": "https://symfony.com/doc/master/bundles/FOSUserBundle/index.html", "issues": "https://github.com/FriendsOfSymfony/FOSUserBundle/issues", - "source": "https://github.com/FriendsOfSymfony/FOSUserBundle/tree/2.0.x" + "source": "https://github.com/FriendsOfSymfony/FOSUserBundle/tree/v2.1.2" }, - "time": "2017-11-29T17:01:21+00:00" + "time": "2018-03-08T08:59:27+00:00" }, { "name": "gedmo/doctrine-extensions", diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 44fd96835..76bf201b1 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -39,7 +39,7 @@ class WallabagRestController extends AbstractFOSRestController $info = [ 'appname' => 'wallabag', 'version' => $this->container->getParameter('wallabag_core.version'), - 'allowed_registration' => $this->container->getParameter('wallabag_user.registration_enabled'), + 'allowed_registration' => $this->container->getParameter('fosuser_registration'), ]; return (new JsonResponse())->setJson($this->get('jms_serializer')->serialize($info, 'json')); diff --git a/src/Wallabag/UserBundle/Controller/RegistrationController.php b/src/Wallabag/UserBundle/Controller/RegistrationController.php deleted file mode 100644 index f81f3a7b4..000000000 --- a/src/Wallabag/UserBundle/Controller/RegistrationController.php +++ /dev/null @@ -1,18 +0,0 @@ -container->getParameter('wallabag_user.registration_enabled')) { - return parent::registerAction($request); - } - - return $this->redirectToRoute('fos_user_security_login', [], 301); - } -} diff --git a/src/Wallabag/UserBundle/Controller/SecurityController.php b/src/Wallabag/UserBundle/Controller/SecurityController.php deleted file mode 100644 index 83fa0b20f..000000000 --- a/src/Wallabag/UserBundle/Controller/SecurityController.php +++ /dev/null @@ -1,21 +0,0 @@ -render('FOSUserBundle:Security:login.html.twig', - array_merge( - $data, - ['registration_enabled' => $this->container->getParameter('wallabag_user.registration_enabled')] - ) - ); - } -} diff --git a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php index 971ce1a0f..4223f8dba 100644 --- a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php @@ -12,14 +12,6 @@ class Configuration implements ConfigurationInterface $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('wallabag_user'); - $rootNode - ->children() - ->booleanNode('registration_enabled') - ->defaultValue(true) - ->end() - ->end() - ; - return $treeBuilder; } } diff --git a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php index 5ca3482e6..eb2870127 100644 --- a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php +++ b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php @@ -16,7 +16,6 @@ class WallabagUserExtension extends Extension $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); - $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']); } public function getAlias() diff --git a/src/Wallabag/UserBundle/EventListener/RegistrationListener.php b/src/Wallabag/UserBundle/EventListener/RegistrationListener.php new file mode 100644 index 000000000..dd928a878 --- /dev/null +++ b/src/Wallabag/UserBundle/EventListener/RegistrationListener.php @@ -0,0 +1,44 @@ +registrationEnabled = $registrationEnabled; + $this->urlGenerator = $urlGenerator; + } + + public static function getSubscribedEvents() + { + return [ + FOSUserEvents::REGISTRATION_INITIALIZE => 'onRegistrationInitialize', + ]; + } + + public function onRegistrationInitialize(GetResponseUserEvent $event) + { + if ($this->registrationEnabled) { + return; + } + + $event->setResponse(new RedirectResponse($this->urlGenerator->generate('fos_user_security_login'), 301)); + } +} diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index 2dcf30111..40f05c672 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -9,6 +9,13 @@ services: - '@=service(''craue_config'').get(''wallabag_support_url'')' - '%domain_name%' + Wallabag\UserBundle\EventListener\RegistrationListener: + arguments: + - '%fosuser_registration%' + - '@router' + tags: + - { name: kernel.event_subscriber } + wallabag_user.password_resetting: class: Wallabag\UserBundle\EventListener\PasswordResettingListener arguments: