mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-24 00:20:28 +00:00
Merge pull request #5782 from yguedidi/upgrade-fosuserbundle
Upgrade FOSUserBundle to 2.1
This commit is contained in:
commit
3c815f7966
12 changed files with 75 additions and 86 deletions
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
|
|
41
composer.lock
generated
41
composer.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\UserBundle\Controller;
|
||||
|
||||
use FOS\UserBundle\Controller\RegistrationController as FOSRegistrationController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class RegistrationController extends FOSRegistrationController
|
||||
{
|
||||
public function registerAction(Request $request)
|
||||
{
|
||||
if ($this->container->getParameter('wallabag_user.registration_enabled')) {
|
||||
return parent::registerAction($request);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('fos_user_security_login', [], 301);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\UserBundle\Controller;
|
||||
|
||||
use FOS\UserBundle\Controller\SecurityController as FOSSecurityController;
|
||||
|
||||
/**
|
||||
* Extends login form in order to pass the registration_enabled parameter.
|
||||
*/
|
||||
class SecurityController extends FOSSecurityController
|
||||
{
|
||||
protected function renderLogin(array $data)
|
||||
{
|
||||
return $this->render('FOSUserBundle:Security:login.html.twig',
|
||||
array_merge(
|
||||
$data,
|
||||
['registration_enabled' => $this->container->getParameter('wallabag_user.registration_enabled')]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\UserBundle\EventListener;
|
||||
|
||||
use FOS\UserBundle\Event\GetResponseUserEvent;
|
||||
use FOS\UserBundle\FOSUserEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class RegistrationListener implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $registrationEnabled;
|
||||
|
||||
/**
|
||||
* @var UrlGeneratorInterface
|
||||
*/
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct($registrationEnabled, UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
$this->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));
|
||||
}
|
||||
}
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue