From e4b46f77ef2984b33f4dff0efea0585c7ab0cfbf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 26 Jun 2016 13:36:53 +0200 Subject: [PATCH 01/13] work --- .../Controller/ConfigController.php | 20 +++++++++++++++++++ .../Resources/translations/messages.da.yml | 3 +++ .../Resources/translations/messages.de.yml | 3 +++ .../Resources/translations/messages.en.yml | 3 +++ .../Resources/translations/messages.es.yml | 3 +++ .../Resources/translations/messages.fa.yml | 3 +++ .../Resources/translations/messages.fr.yml | 3 +++ .../Resources/translations/messages.it.yml | 3 +++ .../Resources/translations/messages.oc.yml | 3 +++ .../Resources/translations/messages.pl.yml | 3 +++ .../Resources/translations/messages.ro.yml | 3 +++ .../Resources/translations/messages.tr.yml | 3 +++ .../themes/material/Config/index.html.twig | 1 + src/Wallabag/UserBundle/Entity/User.php | 12 ++++++++++- 14 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 91cdcae50..0a306d57c 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -251,4 +251,24 @@ class ConfigController extends Controller return $config; } + + /** + * Delete account for current user. + * + * @Route("/account/delete", name="delete_account") + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function deleteAccountAction() + { + $em = $this->get('fos_user.user_manager'); + $em->deleteUser($this->getUser()); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'flashes.account.notice.account_deleted' + ); + + return $this->redirect($this->generateUrl('fos_user_security_logout')); + } } diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 2652a1028..69bfe7b3b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -486,3 +486,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index e0f29b611..f4d134428 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Neuer Client erstellt.' client_deleted: 'Client gelöscht' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b8e981129..6ddb38a0c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -485,6 +485,9 @@ flashes: notice: client_created: 'New client %name% created.' client_deleted: 'Client %name% deleted' + account: + notice: + account_deleted: 'Account deleted' user: notice: added: 'User "%username%" added' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 70633bd76..05b03938d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nuevo cliente creado.' client_deleted: 'Cliente suprimido' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 074ab7a89..3a01a8ed5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -485,3 +485,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6d85a5aea..094458363 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nouveau client %name% créé' client_deleted: 'Client %name% supprimé' + account: + notice: + account_deleted: 'Compte supprimé' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 15f7e7743..93a11aee7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nuovo client creato.' client_deleted: 'Client eliminato' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 1d10be2ae..8cadf9a32 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Novèl client creat' client_deleted: 'Client suprimit' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 547e9c8bf..d392272f0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nowy klient utworzony.' client_deleted: 'Klient usunięty' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 2b1d4f6db..f2bce4428 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -486,3 +486,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 8cfc245ab..d2bf05046 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -485,3 +485,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 270c077f3..cebde1acd 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -167,6 +167,7 @@ {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} {{ form_widget(form.user._token) }} + {{ 'config.user.delete_account' | trans }}
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index d98ae76a5..eb7774cd1 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -25,7 +25,7 @@ use Wallabag\CoreBundle\Entity\Entry; * @UniqueEntity("email") * @UniqueEntity("username") */ -class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface +class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface, \Serializable { /** * @var int @@ -240,4 +240,14 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return false; } + + public function serialize() + { + return serialize($this->id); + } + + public function unserialize($serialized) + { + $this->id = unserialize($serialized); + } } From abb5291cd5dc98211273e5d3b516a6a0ed8b980f Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 1 Jul 2016 10:58:15 +0200 Subject: [PATCH 02/13] CS --- .../CoreBundle/Controller/ConfigController.php | 14 +++++++------- src/Wallabag/UserBundle/Entity/User.php | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 0a306d57c..3cafd1bc6 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -252,13 +252,13 @@ class ConfigController extends Controller return $config; } - /** - * Delete account for current user. - * - * @Route("/account/delete", name="delete_account") - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - */ + /** + * Delete account for current user. + * + * @Route("/account/delete", name="delete_account") + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ public function deleteAccountAction() { $em = $this->get('fos_user.user_manager'); diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index eb7774cd1..ae12e5d54 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -243,11 +243,11 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf public function serialize() { - return serialize($this->id); - } + return serialize($this->id); + } - public function unserialize($serialized) - { - $this->id = unserialize($serialized); - } + public function unserialize($serialized) + { + $this->id = unserialize($serialized); + } } From bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 8 Sep 2016 14:07:36 +0200 Subject: [PATCH 03/13] Added check if there is only one user Added translations and documentation --- docs/en/user/configuration.rst | 2 ++ docs/fr/user/configuration.rst | 2 ++ .../CoreBundle/Controller/ConfigController.php | 14 ++++++++++++++ .../Resources/translations/messages.da.yml | 1 + .../Resources/translations/messages.de.yml | 1 + .../Resources/translations/messages.en.yml | 1 + .../Resources/translations/messages.es.yml | 1 + .../Resources/translations/messages.fa.yml | 1 + .../Resources/translations/messages.fr.yml | 1 + .../Resources/translations/messages.it.yml | 1 + .../Resources/translations/messages.oc.yml | 1 + .../Resources/translations/messages.pl.yml | 1 + .../Resources/translations/messages.ro.yml | 1 + .../Resources/translations/messages.tr.yml | 1 + .../views/themes/baggy/Config/index.html.twig | 3 +++ .../views/themes/material/Config/index.html.twig | 5 ++++- .../UserBundle/Repository/UserRepository.php | 14 ++++++++++++++ 17 files changed, 50 insertions(+), 1 deletion(-) diff --git a/docs/en/user/configuration.rst b/docs/en/user/configuration.rst index f4c55dea6..824878dc8 100644 --- a/docs/en/user/configuration.rst +++ b/docs/en/user/configuration.rst @@ -50,6 +50,8 @@ User information You can change your name, your email address and enable ``Two factor authentication``. +If the wallabag instance has more than one enabled user, you can delete your account here. **Take care, we delete all your data**. + Two factor authentication ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/fr/user/configuration.rst b/docs/fr/user/configuration.rst index 278f0022f..2654e8ad3 100644 --- a/docs/fr/user/configuration.rst +++ b/docs/fr/user/configuration.rst @@ -51,6 +51,8 @@ Mon compte Vous pouvez ici modifier votre nom, votre adresse email et activer la ``Double authentification``. +Si l'instance de wallabag compte plus d'un utilisateur actif, vous pouvez supprimer ici votre compte. **Attention, nous supprimons toutes vos données**. + Double authentification (2FA) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 3cafd1bc6..70a641f7a 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\TaggingRule; use Wallabag\CoreBundle\Form\Type\ConfigType; @@ -148,6 +149,9 @@ class ConfigController extends Controller 'token' => $config->getRssToken(), ], 'twofactor_auth' => $this->getParameter('twofactor_auth'), + 'enabled_users' => $this->getDoctrine() + ->getRepository('WallabagUserBundle:User') + ->getSumEnabledUsers(), ]); } @@ -257,10 +261,20 @@ class ConfigController extends Controller * * @Route("/account/delete", name="delete_account") * + * @throws AccessDeniedHttpException + * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function deleteAccountAction() { + $enabledUsers = $this->getDoctrine() + ->getRepository('WallabagUserBundle:User') + ->getSumEnabledUsers(); + + if ($enabledUsers <= 1) { + throw new AccessDeniedHttpException(); + } + $em = $this->get('fos_user.user_manager'); $em->deleteUser($this->getUser()); diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 69bfe7b3b..4c412592d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -88,6 +88,7 @@ config: name_label: 'Navn' email_label: 'Emailadresse' # twoFactorAuthentication_label: 'Two factor authentication' + # delete_account: 'Delete my account' form_password: old_password_label: 'Gammel adgangskode' new_password_label: 'Ny adgangskode' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index f4d134428..99b79bce8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -88,6 +88,7 @@ config: name_label: 'Name' email_label: 'E-Mail-Adresse' twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung' + # delete_account: 'Delete my account' form_password: old_password_label: 'Altes Kennwort' new_password_label: 'Neues Kennwort' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 6ddb38a0c..94144ed48 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -88,6 +88,7 @@ config: name_label: 'Name' email_label: 'Email' twoFactorAuthentication_label: 'Two factor authentication' + delete_account: 'Delete my account' form_password: old_password_label: 'Current password' new_password_label: 'New password' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 05b03938d..a5e8d7224 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -88,6 +88,7 @@ config: name_label: 'Nombre' email_label: 'Direccion e-mail' twoFactorAuthentication_label: 'Autentificación de dos factores' + # delete_account: 'Delete my account' form_password: old_password_label: 'Contraseña actual' new_password_label: 'Nueva contraseña' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 3a01a8ed5..4b8d9689a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -88,6 +88,7 @@ config: name_label: 'نام' email_label: 'نشانی ایمیل' twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای' + # delete_account: 'Delete my account' form_password: old_password_label: 'رمز قدیمی' new_password_label: 'رمز تازه' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 094458363..67cd5f0e4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -88,6 +88,7 @@ config: name_label: 'Nom' email_label: 'Adresse e-mail' twoFactorAuthentication_label: 'Double authentification' + delete_account: 'Supprimer mon compte' form_password: old_password_label: 'Mot de passe actuel' new_password_label: 'Nouveau mot de passe' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 93a11aee7..55d961f3a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -88,6 +88,7 @@ config: name_label: 'Nome' email_label: 'E-mail' twoFactorAuthentication_label: 'Two factor authentication' + # delete_account: 'Delete my account' form_password: old_password_label: 'Password corrente' new_password_label: 'Nuova password' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 8cadf9a32..5c6b42476 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -88,6 +88,7 @@ config: name_label: 'Nom' email_label: 'Adreça de corrièl' twoFactorAuthentication_label: 'Dobla autentificacion' + # delete_account: 'Delete my account' form_password: old_password_label: 'Senhal actual' new_password_label: 'Senhal novèl' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index d392272f0..be9664272 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -88,6 +88,7 @@ config: name_label: 'Nazwa' email_label: 'Adres email' twoFactorAuthentication_label: 'Autoryzacja dwuetapowa' + # delete_account: 'Delete my account' form_password: old_password_label: 'Stare hasło' new_password_label: 'Nowe hasło' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index f2bce4428..1e52cf0b2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -88,6 +88,7 @@ config: name_label: 'Nume' email_label: 'E-mail' # twoFactorAuthentication_label: 'Two factor authentication' + # delete_account: 'Delete my account' form_password: old_password_label: 'Parola veche' new_password_label: 'Parola nouă' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index d2bf05046..ef5477e13 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -88,6 +88,7 @@ config: name_label: 'İsim' email_label: 'E-posta' twoFactorAuthentication_label: 'İki adımlı doğrulama' + # delete_account: 'Delete my account' form_password: old_password_label: 'Eski şifre' new_password_label: 'Yeni şifre' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index ff7ef73a8..29575272c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -148,6 +148,9 @@ {{ form_widget(form.user._token) }} {{ form_widget(form.user.save) }} + {% if enabled_users > 1 %} + {{ 'config.form_user.delete_account' | trans }} + {% endif %}

{{ 'config.tab_menu.password'|trans }}

diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index cebde1acd..5aa3eabe7 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -167,7 +167,10 @@ {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} {{ form_widget(form.user._token) }} - {{ 'config.user.delete_account' | trans }} + + {% if enabled_users > 1 %} + {{ 'config.form_user.delete_account' | trans }} + {% endif %}
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index 009c4881d..178761e6d 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -38,4 +38,18 @@ class UserRepository extends EntityRepository ->getQuery() ->getSingleResult(); } + + /** + * Count how many users are enabled. + * + * @return int + */ + public function getSumEnabledUsers() + { + return $this->createQueryBuilder('u') + ->select('count(u)') + ->andWhere('u.expired = 0') + ->getQuery() + ->getSingleScalarResult(); + } } From 821bb8768507a16a28e7f98143aba5218691c18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 8 Sep 2016 15:47:03 +0200 Subject: [PATCH 04/13] Added tests --- .../Controller/ConfigControllerTest.php | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 1954c654a..23e7e7860 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -570,4 +570,89 @@ class ConfigControllerTest extends WallabagCoreTestCase $config->set('demo_mode_enabled', 0); $config->set('demo_mode_username', 'wallabag'); } + + public function testDeleteUserButtonVisibility() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config'); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('config.form_user.delete_account', $body[0]); + + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('wallace'); + $user->setExpired(1); + $em->persist($user); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('empty'); + $user->setExpired(1); + $em->persist($user); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('bob'); + $user->setExpired(1); + $em->persist($user); + + $em->flush(); + + $crawler = $client->request('GET', '/config'); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertNotContains('config.form_user.delete_account', $body[0]); + + $client->request('GET', '/account/delete'); + $this->assertEquals(403, $client->getResponse()->getStatusCode()); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('wallace'); + $user->setExpired(0); + $em->persist($user); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('empty'); + $user->setExpired(0); + $em->persist($user); + + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('bob'); + $user->setExpired(0); + $em->persist($user); + + $em->flush(); + } + + public function testDeleteAccount() + { + $this->logInAs('wallace'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config'); + + $deleteLink = $crawler->filter('.red')->last()->link(); + + $client->click($deleteLink); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + $user = $em + ->getRepository('WallabagUserBundle:User') + ->createQueryBuilder('u') + ->where('u.username = :username')->setParameter('username', 'wallace') + ->getQuery() + ->getOneOrNullResult() + ; + + $this->assertTrue(false !== $user); + } } From 71254701b7e5364516b7510e9237c00c678dac1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 8 Sep 2016 16:00:39 +0200 Subject: [PATCH 05/13] Changed tests --- .../Resources/views/themes/baggy/Config/index.html.twig | 2 +- .../Resources/views/themes/material/Config/index.html.twig | 2 +- tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 29575272c..b10db473b 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -149,7 +149,7 @@ {{ form_widget(form.user._token) }} {{ form_widget(form.user.save) }} {% if enabled_users > 1 %} - {{ 'config.form_user.delete_account' | trans }} + {% endif %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 5aa3eabe7..a8a3f9dca 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -169,7 +169,7 @@ {% if enabled_users > 1 %} - {{ 'config.form_user.delete_account' | trans }} + {% endif %}
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 23e7e7860..282bf5707 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -639,7 +639,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/config'); - $deleteLink = $crawler->filter('.red')->last()->link(); + $deleteLink = $crawler->filter('.delete-account')->last()->link(); $client->click($deleteLink); $this->assertEquals(302, $client->getResponse()->getStatusCode()); @@ -653,6 +653,6 @@ class ConfigControllerTest extends WallabagCoreTestCase ->getOneOrNullResult() ; - $this->assertTrue(false !== $user); + $this->assertNull($user); } } From b84026871169cee8cdd4aba892c128beee98e91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 9 Sep 2016 10:08:12 +0200 Subject: [PATCH 06/13] Added a test to check if entries are also deleted --- .../Controller/ConfigControllerTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 282bf5707..75a5e3089 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -637,6 +637,20 @@ class ConfigControllerTest extends WallabagCoreTestCase $this->logInAs('wallace'); $client = $this->getClient(); + // create entry to check after user deletion + // that this entry is also deleted + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + $data = [ + 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', + ]; + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $crawler = $client->request('GET', '/config'); $deleteLink = $crawler->filter('.delete-account')->last()->link(); @@ -654,5 +668,12 @@ class ConfigControllerTest extends WallabagCoreTestCase ; $this->assertNull($user); + + $entries = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUser($this->getLoggedInUserId()); + + $this->assertEmpty($entries); } } From c3396c65ef8532091614ec9ae298ba124d58b2b9 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 14:07:13 +0200 Subject: [PATCH 07/13] Fix some tests --- .../Controller/ConfigControllerTest.php | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 75a5e3089..7929b63d4 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -3,6 +3,8 @@ namespace Tests\Wallabag\CoreBundle\Controller; use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; +use Wallabag\CoreBundle\Entity\Config; +use Wallabag\UserBundle\Entity\User; class ConfigControllerTest extends WallabagCoreTestCase { @@ -583,12 +585,6 @@ class ConfigControllerTest extends WallabagCoreTestCase $em = $client->getContainer()->get('doctrine.orm.entity_manager'); - $user = $em - ->getRepository('WallabagUserBundle:User') - ->findOneByUsername('wallace'); - $user->setExpired(1); - $em->persist($user); - $user = $em ->getRepository('WallabagUserBundle:User') ->findOneByUsername('empty'); @@ -611,12 +607,6 @@ class ConfigControllerTest extends WallabagCoreTestCase $client->request('GET', '/account/delete'); $this->assertEquals(403, $client->getResponse()->getStatusCode()); - $user = $em - ->getRepository('WallabagUserBundle:User') - ->findOneByUsername('wallace'); - $user->setExpired(0); - $em->persist($user); - $user = $em ->getRepository('WallabagUserBundle:User') ->findOneByUsername('empty'); @@ -634,8 +624,31 @@ class ConfigControllerTest extends WallabagCoreTestCase public function testDeleteAccount() { - $this->logInAs('wallace'); $client = $this->getClient(); + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + + $user = new User(); + $user->setName('Wallace'); + $user->setEmail('wallace@wallabag.org'); + $user->setUsername('wallace'); + $user->setPlainPassword('wallace'); + $user->setEnabled(true); + $user->addRole('ROLE_SUPER_ADMIN'); + + $em->persist($user); + + $config = new Config($user); + + $config->setTheme('material'); + $config->setItemsPerPage(30); + $config->setReadingSpeed(1); + $config->setLanguage('en'); + $config->setPocketConsumerKey('xxxxx'); + + $em->persist($config); + $em->flush(); + + $this->logInAs('wallace'); // create entry to check after user deletion // that this entry is also deleted From eed812afd0626697d33f7e9d3bfd8eca138c463d Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 19:39:12 +0200 Subject: [PATCH 08/13] Logout user before deleting it And add a smal description --- .../Controller/ConfigController.php | 35 ++++++++++--------- .../themes/material/Config/index.html.twig | 10 +++++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 70a641f7a..662da2a08 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -261,28 +261,31 @@ class ConfigController extends Controller * * @Route("/account/delete", name="delete_account") * + * @param Request $request + * * @throws AccessDeniedHttpException * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function deleteAccountAction() - { - $enabledUsers = $this->getDoctrine() - ->getRepository('WallabagUserBundle:User') - ->getSumEnabledUsers(); + public function deleteAccountAction(Request $request) + { + $enabledUsers = $this->getDoctrine() + ->getRepository('WallabagUserBundle:User') + ->getSumEnabledUsers(); - if ($enabledUsers <= 1) { - throw new AccessDeniedHttpException(); - } + if ($enabledUsers <= 1) { + throw new AccessDeniedHttpException(); + } - $em = $this->get('fos_user.user_manager'); - $em->deleteUser($this->getUser()); + $user = $this->getUser(); - $this->get('session')->getFlashBag()->add( - 'notice', - 'flashes.account.notice.account_deleted' - ); + // logout current user + $this->get('security.token_storage')->setToken(null); + $request->getSession()->invalidate(); - return $this->redirect($this->generateUrl('fos_user_security_logout')); - } + $em = $this->get('fos_user.user_manager'); + $em->deleteUser($user); + + return $this->redirect($this->generateUrl('fos_user_security_login')); + } } diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index a8a3f9dca..25d259b86 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -169,7 +169,15 @@ {% if enabled_users > 1 %} - +


+ +
+
{{ 'config.delete.title'|trans }}
+

{{ 'config.delete.description'|trans }}

+ +
{% endif %} From 876d77a67d1415c1be56f08e9a2d3b1d294bb61f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 19:39:50 +0200 Subject: [PATCH 09/13] Better display and description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmation message isn’t required since it is written in the delete description --- .../Resources/translations/messages.da.yml | 9 +++++---- .../Resources/translations/messages.de.yml | 9 +++++---- .../Resources/translations/messages.en.yml | 9 +++++---- .../Resources/translations/messages.es.yml | 9 +++++---- .../Resources/translations/messages.fa.yml | 9 +++++---- .../Resources/translations/messages.fr.yml | 9 +++++---- .../Resources/translations/messages.it.yml | 9 +++++---- .../Resources/translations/messages.oc.yml | 9 +++++---- .../Resources/translations/messages.pl.yml | 9 +++++---- .../Resources/translations/messages.ro.yml | 9 +++++---- .../Resources/translations/messages.tr.yml | 9 +++++---- .../views/themes/baggy/Config/index.html.twig | 12 +++++++++--- .../views/themes/material/Config/index.html.twig | 8 ++++---- .../CoreBundle/Controller/ConfigControllerTest.php | 7 ++++--- 14 files changed, 72 insertions(+), 54 deletions(-) diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 4c412592d..2de5d7bd4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -88,7 +88,11 @@ config: name_label: 'Navn' email_label: 'Emailadresse' # twoFactorAuthentication_label: 'Two factor authentication' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Gammel adgangskode' new_password_label: 'Ny adgangskode' @@ -487,6 +491,3 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 99b79bce8..515d43a01 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -88,7 +88,11 @@ config: name_label: 'Name' email_label: 'E-Mail-Adresse' twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Altes Kennwort' new_password_label: 'Neues Kennwort' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Neuer Client erstellt.' client_deleted: 'Client gelöscht' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 94144ed48..43f5a9508 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -88,7 +88,11 @@ config: name_label: 'Name' email_label: 'Email' twoFactorAuthentication_label: 'Two factor authentication' - delete_account: 'Delete my account' + delete: + title: Delete my account (danger zone !) + description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + confirm: Are you really sure? (it can't be UNDONE) + button: Delete my account form_password: old_password_label: 'Current password' new_password_label: 'New password' @@ -486,9 +490,6 @@ flashes: notice: client_created: 'New client %name% created.' client_deleted: 'Client %name% deleted' - account: - notice: - account_deleted: 'Account deleted' user: notice: added: 'User "%username%" added' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index a5e8d7224..adeab2b08 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -88,7 +88,11 @@ config: name_label: 'Nombre' email_label: 'Direccion e-mail' twoFactorAuthentication_label: 'Autentificación de dos factores' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Contraseña actual' new_password_label: 'Nueva contraseña' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Nuevo cliente creado.' client_deleted: 'Cliente suprimido' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 4b8d9689a..0751752b7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -88,7 +88,11 @@ config: name_label: 'نام' email_label: 'نشانی ایمیل' twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'رمز قدیمی' new_password_label: 'رمز تازه' @@ -486,6 +490,3 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 67cd5f0e4..1c32a77c8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -88,7 +88,11 @@ config: name_label: 'Nom' email_label: 'Adresse e-mail' twoFactorAuthentication_label: 'Double authentification' - delete_account: 'Supprimer mon compte' + delete: + title: Supprimer mon compte (attention danger !) + description: Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c'est IRRÉVERSIBLE). Vous serez ensuite déconnecté. + confirm: Vous êtes vraiment sûr ? (c'est IRRÉVERSIBLE !) + button: 'Supprimer mon compte' form_password: old_password_label: 'Mot de passe actuel' new_password_label: 'Nouveau mot de passe' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Nouveau client %name% créé' client_deleted: 'Client %name% supprimé' - account: - notice: - account_deleted: 'Compte supprimé' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 55d961f3a..f662bd55e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -88,7 +88,11 @@ config: name_label: 'Nome' email_label: 'E-mail' twoFactorAuthentication_label: 'Two factor authentication' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Password corrente' new_password_label: 'Nuova password' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Nuovo client creato.' client_deleted: 'Client eliminato' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 5c6b42476..9e314f730 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -88,7 +88,11 @@ config: name_label: 'Nom' email_label: 'Adreça de corrièl' twoFactorAuthentication_label: 'Dobla autentificacion' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Senhal actual' new_password_label: 'Senhal novèl' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Novèl client creat' client_deleted: 'Client suprimit' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index be9664272..9877d59a0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -88,7 +88,11 @@ config: name_label: 'Nazwa' email_label: 'Adres email' twoFactorAuthentication_label: 'Autoryzacja dwuetapowa' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Stare hasło' new_password_label: 'Nowe hasło' @@ -487,6 +491,3 @@ flashes: notice: client_created: 'Nowy klient utworzony.' client_deleted: 'Klient usunięty' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 1e52cf0b2..83246ed3f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -88,7 +88,11 @@ config: name_label: 'Nume' email_label: 'E-mail' # twoFactorAuthentication_label: 'Two factor authentication' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Parola veche' new_password_label: 'Parola nouă' @@ -487,6 +491,3 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index ef5477e13..24dd6ff8c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -88,7 +88,11 @@ config: name_label: 'İsim' email_label: 'E-posta' twoFactorAuthentication_label: 'İki adımlı doğrulama' - # delete_account: 'Delete my account' + delete: + # title: Delete my account (danger zone !) + # description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out. + # confirm: Are you really sure? (it can't be UNDONE) + # button: Delete my account form_password: old_password_label: 'Eski şifre' new_password_label: 'Yeni şifre' @@ -486,6 +490,3 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' - account: - notice: - # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index b10db473b..54508b6dc 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -148,11 +148,17 @@ {{ form_widget(form.user._token) }} {{ form_widget(form.user.save) }} - {% if enabled_users > 1 %} - - {% endif %} + {% if enabled_users > 1 %} +

{{ 'config.form_user.delete.title'|trans }}

+ +

{{ 'config.form_user.delete.description'|trans }}

+ + {% endif %} +

{{ 'config.tab_menu.password'|trans }}

{{ form_start(form.pwd) }} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 25d259b86..8434508d0 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -172,10 +172,10 @@


{% endif %} diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 7929b63d4..5faa0130b 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -581,7 +581,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/config'); $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertContains('config.form_user.delete_account', $body[0]); + $this->assertContains('config.form_user.delete.button', $body[0]); $em = $client->getContainer()->get('doctrine.orm.entity_manager'); @@ -602,7 +602,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/config'); $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertNotContains('config.form_user.delete_account', $body[0]); + $this->assertNotContains('config.form_user.delete.button', $body[0]); $client->request('GET', '/account/delete'); $this->assertEquals(403, $client->getResponse()->getStatusCode()); @@ -649,6 +649,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->flush(); $this->logInAs('wallace'); + $loggedInUserId = $this->getLoggedInUserId(); // create entry to check after user deletion // that this entry is also deleted @@ -685,7 +686,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $entries = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findByUser($this->getLoggedInUserId()); + ->findByUser($loggedInUserId); $this->assertEmpty($entries); } From 3f604467564e86623513107161587f7e34d4f369 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 20:26:06 +0200 Subject: [PATCH 10/13] Fix PostgreSQL query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PostgreSQL doesn’t like when we compare interger and boolean :) --- src/Wallabag/UserBundle/Repository/UserRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index 178761e6d..445edb3c1 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -48,7 +48,7 @@ class UserRepository extends EntityRepository { return $this->createQueryBuilder('u') ->select('count(u)') - ->andWhere('u.expired = 0') + ->andWhere('u.expired = false') ->getQuery() ->getSingleScalarResult(); } From a730cae384e7c83fe35c5ee0210204dede9b1678 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 20:33:21 +0200 Subject: [PATCH 11/13] Bonus: display driver in install command --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index cc7c2c94c..42982e4a4 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -77,7 +77,7 @@ class InstallCommand extends ContainerAwareCommand // testing if database driver exists $fulfilled = true; - $label = 'PDO Driver'; + $label = 'PDO Driver (%s)'; $status = 'OK!'; $help = ''; @@ -87,7 +87,7 @@ class InstallCommand extends ContainerAwareCommand $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; } - $rows[] = [$label, $status, $help]; + $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help]; // testing if connection to the database can be etablished $label = 'Database connection'; From 7ac3e575f1285a07987346461cee9445ac8c0b3b Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 20:35:16 +0200 Subject: [PATCH 12/13] CS --- .../Controller/ConfigController.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 662da2a08..abd35c028 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -256,17 +256,17 @@ class ConfigController extends Controller return $config; } - /** - * Delete account for current user. - * - * @Route("/account/delete", name="delete_account") - * - * @param Request $request - * - * @throws AccessDeniedHttpException - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - */ + /** + * Delete account for current user. + * + * @Route("/account/delete", name="delete_account") + * + * @param Request $request + * + * @throws AccessDeniedHttpException + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ public function deleteAccountAction(Request $request) { $enabledUsers = $this->getDoctrine() From 9810f30821105f6340b64e8bdca9f91b9da8a6ba Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 21:16:40 +0200 Subject: [PATCH 13/13] Remove unnecessary user serialization --- src/Wallabag/UserBundle/Entity/User.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index ae12e5d54..d98ae76a5 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -25,7 +25,7 @@ use Wallabag\CoreBundle\Entity\Entry; * @UniqueEntity("email") * @UniqueEntity("username") */ -class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface, \Serializable +class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface { /** * @var int @@ -240,14 +240,4 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return false; } - - public function serialize() - { - return serialize($this->id); - } - - public function unserialize($serialized) - { - $this->id = unserialize($serialized); - } }