aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php10
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php15
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php10
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php30
5 files changed, 60 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 93520f9a..2e241757 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -327,6 +327,16 @@ class InstallCommand extends ContainerAwareCommand
327 'value' => '1', 327 'value' => '1',
328 'section' => 'analytics', 328 'section' => 'analytics',
329 ], 329 ],
330 [
331 'name' => 'demo_mode_enabled',
332 'value' => '0',
333 'section' => 'misc',
334 ],
335 [
336 'name' => 'demo_mode_username',
337 'value' => 'wallabag',
338 'section' => 'misc',
339 ],
330 ]; 340 ];
331 341
332 foreach ($settings as $setting) { 342 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 6eb621d8..1791eac2 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -57,13 +57,16 @@ class ConfigController extends Controller
57 $pwdForm->handleRequest($request); 57 $pwdForm->handleRequest($request);
58 58
59 if ($pwdForm->isValid()) { 59 if ($pwdForm->isValid()) {
60 $user->setPlainPassword($pwdForm->get('new_password')->getData()); 60 if ($this->get('craue_config')->get('demo_mode_enabled') && $this->get('craue_config')->get('demo_mode_username') === $user->getUsername()) {
61 $userManager->updateUser($user, true); 61 $message = 'In demonstration mode, you can\'t change password for this user.';
62 } else {
63 $message = 'Password updated';
62 64
63 $this->get('session')->getFlashBag()->add( 65 $user->setPlainPassword($pwdForm->get('new_password')->getData());
64 'notice', 66 $userManager->updateUser($user, true);
65 'Password updated' 67 }
66 ); 68
69 $this->get('session')->getFlashBag()->add('notice', $message);
67 70
68 return $this->redirect($this->generateUrl('config').'#set4'); 71 return $this->redirect($this->generateUrl('config').'#set4');
69 } 72 }
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
index 10b60f30..1f4cafdf 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
@@ -125,6 +125,16 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
125 'value' => '1', 125 'value' => '1',
126 'section' => 'analytics', 126 'section' => 'analytics',
127 ], 127 ],
128 [
129 'name' => 'demo_mode_enabled',
130 'value' => '0',
131 'section' => 'misc',
132 ],
133 [
134 'name' => 'demo_mode_username',
135 'value' => 'wallabag',
136 'section' => 'misc',
137 ],
128 ]; 138 ];
129 139
130 foreach ($settings as $setting) { 140 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 54161646..65280ebc 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -175,6 +175,7 @@ Entry deleted: "Article supprimé"
175Tagging rule deleted: "Règle supprimée" 175Tagging rule deleted: "Règle supprimée"
176Tagging rules updated: "Règles mises à jour" 176Tagging rules updated: "Règles mises à jour"
177User "%username%" added: 'Utilisateur "%username%" ajouté' 177User "%username%" added: 'Utilisateur "%username%" ajouté'
178In demonstration mode, you can't change password for this user.: 'En démo, vous ne pouvez pas changer le mot de passe de cet utilisateur.'
178 179
179# Entry 180# Entry
180Mark as read: 'Marquer comme lu' 181Mark as read: 'Marquer comme lu'
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 6c370a2d..2af93ffe 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -577,4 +577,34 @@ class ConfigControllerTest extends WallabagCoreTestCase
577 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 577 $this->assertEquals(403, $client->getResponse()->getStatusCode());
578 $this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent()); 578 $this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent());
579 } 579 }
580
581 public function testDemoMode()
582 {
583 $this->logInAs('admin');
584 $client = $this->getClient();
585
586 $config = $client->getContainer()->get('craue_config');
587 $config->set('demo_mode_enabled', 1);
588 $config->set('demo_mode_username', 'admin');
589
590 $crawler = $client->request('GET', '/config');
591
592 $this->assertEquals(200, $client->getResponse()->getStatusCode());
593
594 $form = $crawler->filter('button[id=change_passwd_save]')->form();
595
596 $data = array(
597 'change_passwd[old_password]' => 'mypassword',
598 'change_passwd[new_password][first]' => 'mypassword',
599 'change_passwd[new_password][second]' => 'mypassword',
600 );
601
602 $client->submit($form, $data);
603
604 $this->assertEquals(302, $client->getResponse()->getStatusCode());
605 $this->assertContains('In demonstration mode, you can\'t change password for this user.', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
606
607 $config->set('demo_mode_enabled', 0);
608 $config->set('demo_mode_username', 'wallabag');
609 }
580} 610}