aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-07-02 14:35:52 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-08-23 07:40:36 +0200
commitde3d716ae4e8ca98dabdcb2ec9c18219e05856f7 (patch)
treedc1198b88d23b81130026057ddebb1d687c643e6
parent79efca1e6ff28362d4bd2713f68205294cdd07de (diff)
downloadwallabag-de3d716ae4e8ca98dabdcb2ec9c18219e05856f7.tar.gz
wallabag-de3d716ae4e8ca98dabdcb2ec9c18219e05856f7.tar.zst
wallabag-de3d716ae4e8ca98dabdcb2ec9c18219e05856f7.zip
Add option to disable registration
-rw-r--r--app/config/config.yml3
-rw-r--r--app/config/parameters.yml.dist1
-rw-r--r--src/Wallabag/UserBundle/Controller/RegistrationController.php20
-rw-r--r--src/Wallabag/UserBundle/Controller/SecurityController.php18
-rw-r--r--src/Wallabag/UserBundle/DependencyInjection/Configuration.php8
-rw-r--r--src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php1
-rw-r--r--src/Wallabag/UserBundle/Resources/views/Security/login.html.twig4
7 files changed, 54 insertions, 1 deletions
diff --git a/app/config/config.yml b/app/config/config.yml
index 80754393..cad51e6c 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -50,6 +50,9 @@ wallabag_core:
50 rss_limit: 50 50 rss_limit: 50
51 reading_speed: 1 51 reading_speed: 1
52 52
53wallabag_user:
54 registration_enabled: "%registration_enabled%"
55
53wallabag_import: 56wallabag_import:
54 allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] 57 allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']
55 resource_dir: "%kernel.root_dir%/../web/uploads/import" 58 resource_dir: "%kernel.root_dir%/../web/uploads/import"
diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist
index d45839f4..d092e139 100644
--- a/app/config/parameters.yml.dist
+++ b/app/config/parameters.yml.dist
@@ -34,6 +34,7 @@ parameters:
34 twofactor_sender: no-reply@wallabag.org 34 twofactor_sender: no-reply@wallabag.org
35 35
36 # fosuser stuff 36 # fosuser stuff
37 fosuser_registration: true
37 fosuser_confirmation: true 38 fosuser_confirmation: true
38 39
39 from_email: no-reply@wallabag.org 40 from_email: no-reply@wallabag.org
diff --git a/src/Wallabag/UserBundle/Controller/RegistrationController.php b/src/Wallabag/UserBundle/Controller/RegistrationController.php
new file mode 100644
index 00000000..bba27cfb
--- /dev/null
+++ b/src/Wallabag/UserBundle/Controller/RegistrationController.php
@@ -0,0 +1,20 @@
1<?php
2
3namespace Wallabag\UserBundle\Controller;
4
5use FOS\UserBundle\Controller\RegistrationController as FOSRegistrationController;
6use Symfony\Component\HttpFoundation\Request;
7
8class RegistrationController extends FOSRegistrationController
9{
10 public function registerAction(Request $request)
11 {
12 if ($this->container->getParameter('wallabag_user.registration_enabled')) {
13 parent::registerAction($request);
14 }
15 else
16 {
17 return $this->redirectToRoute('fos_user_security_login', array(), 301);
18 }
19 }
20}
diff --git a/src/Wallabag/UserBundle/Controller/SecurityController.php b/src/Wallabag/UserBundle/Controller/SecurityController.php
new file mode 100644
index 00000000..a5f93763
--- /dev/null
+++ b/src/Wallabag/UserBundle/Controller/SecurityController.php
@@ -0,0 +1,18 @@
1<?php
2
3namespace Wallabag\UserBundle\Controller;
4
5use FOS\UserBundle\Controller\SecurityController as FOSSecurityController;
6
7class SecurityController extends FOSSecurityController
8{
9 protected function renderLogin(array $data)
10 {
11 return $this->render('FOSUserBundle:Security:login.html.twig',
12 array_merge(
13 $data,
14 array('registration_enabled' => $this->container->getParameter('wallabag_user.registration_enabled'))
15 )
16 );
17 }
18}
diff --git a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
index 4223f8db..971ce1a0 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/Configuration.php
@@ -12,6 +12,14 @@ class Configuration implements ConfigurationInterface
12 $treeBuilder = new TreeBuilder(); 12 $treeBuilder = new TreeBuilder();
13 $rootNode = $treeBuilder->root('wallabag_user'); 13 $rootNode = $treeBuilder->root('wallabag_user');
14 14
15 $rootNode
16 ->children()
17 ->booleanNode('registration_enabled')
18 ->defaultValue(true)
19 ->end()
20 ->end()
21 ;
22
15 return $treeBuilder; 23 return $treeBuilder;
16 } 24 }
17} 25}
diff --git a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
index c12a8937..99040f69 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
@@ -16,6 +16,7 @@ class WallabagUserExtension extends Extension
16 16
17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
18 $loader->load('services.yml'); 18 $loader->load('services.yml');
19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
19 } 20 }
20 21
21 public function getAlias() 22 public function getAlias()
diff --git a/src/Wallabag/UserBundle/Resources/views/Security/login.html.twig b/src/Wallabag/UserBundle/Resources/views/Security/login.html.twig
index 8474b497..13a903ab 100644
--- a/src/Wallabag/UserBundle/Resources/views/Security/login.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/Security/login.html.twig
@@ -33,7 +33,9 @@
33 </div> 33 </div>
34 <div class="card-action center"> 34 <div class="card-action center">
35 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" /> 35 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
36 <a href="{{ path('fos_user_registration_register') }}" class="waves-effect waves-light grey btn">{{ 'security.login.register'|trans }}</a> 36 {% if registration_enabled %}
37 <a href="{{ path('fos_user_registration_register') }}" class="waves-effect waves-light grey btn">{{ 'security.login.register'|trans }}</a>
38 {% endif %}
37 <button class="btn waves-effect waves-light" type="submit" name="send"> 39 <button class="btn waves-effect waves-light" type="submit" name="send">
38 {{ 'security.login.submit'|trans }} 40 {{ 'security.login.submit'|trans }}
39 <i class="material-icons right">send</i> 41 <i class="material-icons right">send</i>