add a username for demonstration mode

This commit is contained in:
Nicolas Lœuillet 2016-02-18 13:31:22 +01:00 committed by Jeremy Benoist
parent c3b43c8a3e
commit d8d56448c9
5 changed files with 14 additions and 10 deletions

View file

@ -46,5 +46,6 @@ parameters:
from_email: no-reply@wallabag.org 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: false
demo_username: wallabag

View file

@ -36,5 +36,6 @@ parameters:
from_email: no-reply@wallabag.org 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: false
demo_username: wallabag

View file

@ -36,5 +36,6 @@ parameters:
from_email: no-reply@wallabag.org 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: false
demo_username: wallabag

View file

@ -36,5 +36,6 @@ parameters:
from_email: no-reply@wallabag.org 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: false
demo_username: wallabag

View file

@ -57,7 +57,12 @@ class ConfigController extends Controller
$pwdForm->handleRequest($request); $pwdForm->handleRequest($request);
if ($pwdForm->isValid()) { if ($pwdForm->isValid()) {
if ($this->getParameter('demo') === false) { if ($this->getParameter('demo') === true && $this->getParameter('demo_username') === $user->getUsername()) {
$this->get('session')->getFlashBag()->add(
'notice',
'In demonstration mode, you can\'t change password for this user.'
);
} else {
$user->setPlainPassword($pwdForm->get('new_password')->getData()); $user->setPlainPassword($pwdForm->get('new_password')->getData());
$userManager->updateUser($user, true); $userManager->updateUser($user, true);
@ -65,11 +70,6 @@ class ConfigController extends Controller
'notice', 'notice',
'Password updated' 'Password updated'
); );
} else {
$this->get('session')->getFlashBag()->add(
'notice',
'In demonstration mode, you can\'t change password.'
);
} }
return $this->redirect($this->generateUrl('config').'#set4'); return $this->redirect($this->generateUrl('config').'#set4');