mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Merge pull request #1683 from wallabag/v2-demo
Demonstration mode to prevent password changes
This commit is contained in:
commit
2aadeea8cd
7 changed files with 64 additions and 6 deletions
|
@ -25,3 +25,5 @@ modify_settings: "apply"
|
||||||
piwik_host: Host of your website in Piwik
|
piwik_host: Host of your website in Piwik
|
||||||
piwik_site_id: ID of your website in Piwik
|
piwik_site_id: ID of your website in Piwik
|
||||||
piwik_enabled: Enable Piwik
|
piwik_enabled: Enable Piwik
|
||||||
|
demo_mode_enabled: "Enable demo mode ? (only used for the wallabag public demo)"
|
||||||
|
demo_mode_username: "Demo user"
|
||||||
|
|
|
@ -25,3 +25,5 @@ modify_settings: "appliquer"
|
||||||
piwik_host: URL de votre site dans Piwik
|
piwik_host: URL de votre site dans Piwik
|
||||||
piwik_site_id: ID de votre site dans Piwik
|
piwik_site_id: ID de votre site dans Piwik
|
||||||
piwik_enabled: Activer Piwik
|
piwik_enabled: Activer Piwik
|
||||||
|
demo_mode_enabled: "Activer le mode démo ? (utiliser uniquement pour la démo publique de wallabag)"
|
||||||
|
demo_mode_username: "Utilisateur de la démo"
|
||||||
|
|
|
@ -327,6 +327,16 @@ class InstallCommand extends ContainerAwareCommand
|
||||||
'value' => '1',
|
'value' => '1',
|
||||||
'section' => 'analytics',
|
'section' => 'analytics',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'demo_mode_enabled',
|
||||||
|
'value' => '0',
|
||||||
|
'section' => 'misc',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'demo_mode_username',
|
||||||
|
'value' => 'wallabag',
|
||||||
|
'section' => 'misc',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
|
|
|
@ -57,13 +57,16 @@ class ConfigController extends Controller
|
||||||
$pwdForm->handleRequest($request);
|
$pwdForm->handleRequest($request);
|
||||||
|
|
||||||
if ($pwdForm->isValid()) {
|
if ($pwdForm->isValid()) {
|
||||||
|
if ($this->get('craue_config')->get('demo_mode_enabled') && $this->get('craue_config')->get('demo_mode_username') === $user->getUsername()) {
|
||||||
|
$message = 'In demonstration mode, you can\'t change password for this user.';
|
||||||
|
} else {
|
||||||
|
$message = 'Password updated';
|
||||||
|
|
||||||
$user->setPlainPassword($pwdForm->get('new_password')->getData());
|
$user->setPlainPassword($pwdForm->get('new_password')->getData());
|
||||||
$userManager->updateUser($user, true);
|
$userManager->updateUser($user, true);
|
||||||
|
}
|
||||||
|
|
||||||
$this->get('session')->getFlashBag()->add(
|
$this->get('session')->getFlashBag()->add('notice', $message);
|
||||||
'notice',
|
|
||||||
'Password updated'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('config').'#set4');
|
return $this->redirect($this->generateUrl('config').'#set4');
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,16 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
|
||||||
'value' => '1',
|
'value' => '1',
|
||||||
'section' => 'analytics',
|
'section' => 'analytics',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'demo_mode_enabled',
|
||||||
|
'value' => '0',
|
||||||
|
'section' => 'misc',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'demo_mode_username',
|
||||||
|
'value' => 'wallabag',
|
||||||
|
'section' => 'misc',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
|
|
|
@ -175,6 +175,7 @@ Entry deleted: "Article supprimé"
|
||||||
Tagging rule deleted: "Règle supprimée"
|
Tagging rule deleted: "Règle supprimée"
|
||||||
Tagging rules updated: "Règles mises à jour"
|
Tagging rules updated: "Règles mises à jour"
|
||||||
User "%username%" added: 'Utilisateur "%username%" ajouté'
|
User "%username%" added: 'Utilisateur "%username%" ajouté'
|
||||||
|
In 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.'
|
||||||
|
|
||||||
# Entry
|
# Entry
|
||||||
Mark as read: 'Marquer comme lu'
|
Mark as read: 'Marquer comme lu'
|
||||||
|
|
|
@ -577,4 +577,34 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||||
$this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent());
|
$this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDemoMode()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$config = $client->getContainer()->get('craue_config');
|
||||||
|
$config->set('demo_mode_enabled', 1);
|
||||||
|
$config->set('demo_mode_username', 'admin');
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/config');
|
||||||
|
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$form = $crawler->filter('button[id=change_passwd_save]')->form();
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'change_passwd[old_password]' => 'mypassword',
|
||||||
|
'change_passwd[new_password][first]' => 'mypassword',
|
||||||
|
'change_passwd[new_password][second]' => 'mypassword',
|
||||||
|
);
|
||||||
|
|
||||||
|
$client->submit($form, $data);
|
||||||
|
|
||||||
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
$this->assertContains('In demonstration mode, you can\'t change password for this user.', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
|
||||||
|
|
||||||
|
$config->set('demo_mode_enabled', 0);
|
||||||
|
$config->set('demo_mode_username', 'wallabag');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue