mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-06 23:48:48 +00:00
Merge pull request #2186 from wallabag/addRegistration
Add option to disable registration
This commit is contained in:
commit
a1ab7d1d32
9 changed files with 71 additions and 2 deletions
|
@ -50,6 +50,9 @@ wallabag_core:
|
||||||
rss_limit: 50
|
rss_limit: 50
|
||||||
reading_speed: 1
|
reading_speed: 1
|
||||||
|
|
||||||
|
wallabag_user:
|
||||||
|
registration_enabled: "%fosuser_registration%"
|
||||||
|
|
||||||
wallabag_import:
|
wallabag_import:
|
||||||
allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']
|
allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']
|
||||||
resource_dir: "%kernel.root_dir%/../web/uploads/import"
|
resource_dir: "%kernel.root_dir%/../web/uploads/import"
|
||||||
|
|
|
@ -34,6 +34,7 @@ parameters:
|
||||||
twofactor_sender: no-reply@wallabag.org
|
twofactor_sender: no-reply@wallabag.org
|
||||||
|
|
||||||
# fosuser stuff
|
# fosuser stuff
|
||||||
|
fosuser_registration: true
|
||||||
fosuser_confirmation: true
|
fosuser_confirmation: true
|
||||||
|
|
||||||
from_email: no-reply@wallabag.org
|
from_email: no-reply@wallabag.org
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
21
src/Wallabag/UserBundle/Controller/SecurityController.php
Normal file
21
src/Wallabag/UserBundle/Controller/SecurityController.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?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,6 +12,14 @@ class Configuration implements ConfigurationInterface
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
$rootNode = $treeBuilder->root('wallabag_user');
|
$rootNode = $treeBuilder->root('wallabag_user');
|
||||||
|
|
||||||
|
$rootNode
|
||||||
|
->children()
|
||||||
|
->booleanNode('registration_enabled')
|
||||||
|
->defaultValue(true)
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class WallabagUserExtension extends Extension
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||||
$loader->load('services.yml');
|
$loader->load('services.yml');
|
||||||
|
$container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAlias()
|
public function getAlias()
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action center">
|
<div class="card-action center">
|
||||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
|
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
|
||||||
|
{% if registration_enabled %}
|
||||||
<a href="{{ path('fos_user_registration_register') }}" class="waves-effect waves-light grey btn">{{ 'security.login.register'|trans }}</a>
|
<a href="{{ path('fos_user_registration_register') }}" class="waves-effect waves-light grey btn">{{ 'security.login.register'|trans }}</a>
|
||||||
|
{% endif %}
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="send">
|
<button class="btn waves-effect waves-light" type="submit" name="send">
|
||||||
{{ 'security.login.submit'|trans }}
|
{{ 'security.login.submit'|trans }}
|
||||||
<i class="material-icons right">send</i>
|
<i class="material-icons right">send</i>
|
||||||
|
|
|
@ -33,7 +33,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure next tests will have a clean database
|
* Ensure next tests will have a clean database.
|
||||||
*/
|
*/
|
||||||
public static function tearDownAfterClass()
|
public static function tearDownAfterClass()
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,4 +69,19 @@ class SecurityControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertTrue($user->isTrustedComputer('ABCDEF'));
|
$this->assertTrue($user->isTrustedComputer('ABCDEF'));
|
||||||
$this->assertFalse($user->isTrustedComputer('FEDCBA'));
|
$this->assertFalse($user->isTrustedComputer('FEDCBA'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEnabledRegistration()
|
||||||
|
{
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
if (!$client->getContainer()->getParameter('fosuser_registration')) {
|
||||||
|
$this->markTestSkipped('fosuser_registration is not enabled.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$client->followRedirects();
|
||||||
|
$crawler = $client->request('GET', '/register');
|
||||||
|
$this->assertContains('registration.submit', $crawler->filter('body')->extract(['_text'])[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue