mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-11 17:51:02 +00:00
Use a listener to skip registration
This commit is contained in:
parent
bfc28d4c0b
commit
007bd31bee
4 changed files with 51 additions and 24 deletions
|
@ -41,12 +41,6 @@ homepage:
|
||||||
fos_user:
|
fos_user:
|
||||||
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
|
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
|
||||||
|
|
||||||
fos_user_registration_register:
|
|
||||||
path: /register
|
|
||||||
defaults:
|
|
||||||
_controller: Wallabag\UserBundle\Controller\RegistrationController::registerAction
|
|
||||||
methods: [GET, POST]
|
|
||||||
|
|
||||||
fos_oauth_server_token:
|
fos_oauth_server_token:
|
||||||
resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml"
|
resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml"
|
||||||
|
|
||||||
|
|
|
@ -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('fosuser_registration')) {
|
|
||||||
return parent::registerAction($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirectToRoute('fos_user_security_login', [], 301);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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'')'
|
- '@=service(''craue_config'').get(''wallabag_support_url'')'
|
||||||
- '%domain_name%'
|
- '%domain_name%'
|
||||||
|
|
||||||
|
Wallabag\UserBundle\EventListener\RegistrationListener:
|
||||||
|
arguments:
|
||||||
|
- '%fosuser_registration%'
|
||||||
|
- '@router'
|
||||||
|
tags:
|
||||||
|
- { name: kernel.event_subscriber }
|
||||||
|
|
||||||
wallabag_user.password_resetting:
|
wallabag_user.password_resetting:
|
||||||
class: Wallabag\UserBundle\EventListener\PasswordResettingListener
|
class: Wallabag\UserBundle\EventListener\PasswordResettingListener
|
||||||
arguments:
|
arguments:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue