From d8d56448c993bdf4811a193f96e5ff44ed026417 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 18 Feb 2016 13:31:22 +0100 Subject: [PATCH] add a username for demonstration mode --- app/config/parameters.yml.dist | 3 ++- app/config/tests/parameters.yml.dist.mysql | 3 ++- app/config/tests/parameters.yml.dist.pgsql | 3 ++- app/config/tests/parameters.yml.dist.sqlite | 3 ++- .../CoreBundle/Controller/ConfigController.php | 12 ++++++------ 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index b71e5393..5f22b147 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -46,5 +46,6 @@ parameters: from_email: no-reply@wallabag.org - # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the default account + # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the demo_user account demo: false + demo_username: wallabag diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index 1e21e26a..126e11eb 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -36,5 +36,6 @@ parameters: from_email: no-reply@wallabag.org - # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the default account + # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the demo_user account demo: false + demo_username: wallabag diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index 3e1b0b81..8fc33a94 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -36,5 +36,6 @@ parameters: from_email: no-reply@wallabag.org - # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the default account + # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the demo_user account demo: false + demo_username: wallabag diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index eedb8469..8e3d49b3 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -36,5 +36,6 @@ parameters: from_email: no-reply@wallabag.org - # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the default account + # this parameter is only used for the wallabag public demo, it means user won't be able to change the password of the demo_user account demo: false + demo_username: wallabag diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 31b59845..9ff79ba9 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -57,18 +57,18 @@ class ConfigController extends Controller $pwdForm->handleRequest($request); if ($pwdForm->isValid()) { - if ($this->getParameter('demo') === false) { - $user->setPlainPassword($pwdForm->get('new_password')->getData()); - $userManager->updateUser($user, true); - + if ($this->getParameter('demo') === true && $this->getParameter('demo_username') === $user->getUsername()) { $this->get('session')->getFlashBag()->add( 'notice', - 'Password updated' + 'In demonstration mode, you can\'t change password for this user.' ); } else { + $user->setPlainPassword($pwdForm->get('new_password')->getData()); + $userManager->updateUser($user, true); + $this->get('session')->getFlashBag()->add( 'notice', - 'In demonstration mode, you can\'t change password.' + 'Password updated' ); } -- 2.41.0