]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge remote-tracking branch 'origin/master' into 2.2
authorJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 11 Oct 2016 19:01:30 +0000 (21:01 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Tue, 11 Oct 2016 19:01:30 +0000 (21:01 +0200)
19 files changed:
docs/en/user/configuration.rst
docs/fr/user/configuration.rst
src/Wallabag/CoreBundle/Command/InstallCommand.php
src/Wallabag/CoreBundle/Controller/ConfigController.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
src/Wallabag/UserBundle/Repository/UserRepository.php
tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php

index f4c55dea6e8cc757fece1ce38c5eae277661520e..824878dc825dede60c91fccd7903b04ff2dbb613 100644 (file)
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 278f0022f8f492a1566ecb159452ad8da373b8f3..2654e8ad3839201e2fef5ff43e83265ee83ed405 100644 (file)
@@ -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)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 8e438229f9584d788b299ce51d634939e791eac2..591107821c854345f8e133fbb6d219f19b27fffa 100644 (file)
@@ -77,7 +77,7 @@ class InstallCommand extends ContainerAwareCommand
 
         // testing if database driver exists
         $fulfilled = true;
-        $label = '<comment>PDO Driver</comment>';
+        $label = '<comment>PDO Driver (%s)</comment>';
         $status = '<info>OK!</info>';
         $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 = '<comment>Database connection</comment>';
index 91cdcae506fe75f2176f84fbe3c31911c29d3a66..abd35c028b8aa3681e552ef62557d21eca514ad3 100644 (file)
@@ -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(),
         ]);
     }
 
@@ -251,4 +255,37 @@ 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
+     */
+    public function deleteAccountAction(Request $request)
+    {
+        $enabledUsers = $this->getDoctrine()
+            ->getRepository('WallabagUserBundle:User')
+            ->getSumEnabledUsers();
+
+        if ($enabledUsers <= 1) {
+            throw new AccessDeniedHttpException();
+        }
+
+        $user = $this->getUser();
+
+        // logout current user
+        $this->get('security.token_storage')->setToken(null);
+        $request->getSession()->invalidate();
+
+        $em = $this->get('fos_user.user_manager');
+        $em->deleteUser($user);
+
+        return $this->redirect($this->generateUrl('fos_user_security_login'));
+    }
 }
index bb23b5fedfbce9b8090e95aadbd993496faf51c4..f5548a217a42b0e553c7a0cc85a6fe804a9d858d 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Navn'
         email_label: 'Emailadresse'
         # twoFactorAuthentication_label: 'Two factor authentication'
+        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'
index 079cfece9bbe35f9ea62f62378c97cb7933e15d1..9edd7fb702a5693c8dc19c689ea56a1c2aa8d039 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Name'
         email_label: 'E-Mail-Adresse'
         twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung'
+        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'
index 34a6f74e093b124c6500265d878f712bd48fdb4f..b86145a0f05c0a45a9b424a03fc1a43d5c7d884a 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Name'
         email_label: 'Email'
         twoFactorAuthentication_label: 'Two factor authentication'
+        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'
index 29f0676ee07a91aaaf4f68fc28e9f81776329cee..b7187f50a20eb6f6bbb2c3ecd278af9cf7c5dd2a 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Nombre'
         email_label: 'Direccion e-mail'
         twoFactorAuthentication_label: 'Autentificación de dos factores'
+        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'
index 074ab7a8981c84666abd240110ff85f03358cc3c..0751752b762b790374f324831b4b58b0bbfe8ffb 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'نام'
         email_label: 'نشانی ایمیل'
         twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای'
+        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: 'رمز تازه'
index 55453b6cee7b148faecae1ed2ef6175d161d0d1c..8d19ccb1f39df12660e6621433190416d74bd728 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Nom'
         email_label: 'Adresse e-mail'
         twoFactorAuthentication_label: 'Double authentification'
+        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'
index 67205c6d1694ddec19041f67f85796831e8937b9..4d3452ea7762131b0c3e8b0c2210453219e8a02f 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Nome'
         email_label: 'E-mail'
         twoFactorAuthentication_label: 'Two factor authentication'
+        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'
index 25e5f05a1b0f1eff2421298d59341fa589dd5ed9..f14213c606a8c85882452ee6f88e5b3e81e191a6 100644 (file)
@@ -25,13 +25,13 @@ menu:
         internal_settings: 'Configuracion interna'
         import: 'Importar'
         howto: 'Ajuda'
-        developer: 'Desvolopador'
+        developer: 'Desvolopaire'
         logout: 'Desconnexion'
         about: 'A prepaus'
         search: 'Cercar'
         save_link: 'Enregistrar un novèl article'
         back_to_unread: 'Tornar als articles pas legits'
-        # users_management: 'Users management'
+        users_management: 'Gestion dels utilizaires'
     top:
         add_new_entry: 'Enregistrar un novèl article'
         search: 'Cercar'
@@ -46,7 +46,7 @@ footer:
         social: 'Social'
         powered_by: 'propulsat per'
         about: 'A prepaus'
-    # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
+    stats: "Dempuèi %user_creation% avètz legit %nb_archives% articles. Es a l'entorn de %per_day% per jorn !"
 
 config:
     page_title: 'Configuracion'
@@ -88,6 +88,11 @@ config:
         name_label: 'Nom'
         email_label: 'Adreça de corrièl'
         twoFactorAuthentication_label: 'Dobla autentificacion'
+        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'
@@ -96,7 +101,7 @@ config:
         if_label: 'se'
         then_tag_as_label: 'alara atribuir las etiquetas'
         delete_rule_label: 'suprimir'
-        # edit_rule_label: 'edit'
+        edit_rule_label: 'modificar'
         rule_label: 'Règla'
         tags_label: 'Etiquetas'
         faq:
@@ -209,7 +214,7 @@ entry:
         is_public_label: 'Public'
         save_label: 'Enregistrar'
     public:
-        # shared_by_wallabag: "This article has been shared by <a href='%wallabag_instance%'>wallabag</a>"
+        shared_by_wallabag: "Aqueste article es estat partejat per <a href='%wallabag_instance%'>wallabag</a>"
 
 about:
     page_title: 'A prepaus'
@@ -265,14 +270,14 @@ howto:
 
 quickstart:
     page_title: 'Per ben començar'
-    # more: 'More…'
+    more: 'Mai…'
     intro:
         title: 'Benvenguda sus wallabag !'
         paragraph_1: "Anem vos guidar per far lo torn de la proprietat e vos presentar unas fonccionalitats que vos poirián interessar per vos apropriar aquesta aisina."
         paragraph_2: 'Seguètz-nos '
     configure:
-        title: "Configuratz l'aplicacio"
-        # description: 'In order to have an application which suits you, have a look into the configuration of wallabag.'
+        title: "Configuratz l'aplicacion"
+        description: "Per fin d'aver una aplicacion que vos va ben, anatz veire la configuracion de wallabag."
         language: "Cambiatz la lenga e l'estil de l'aplicacion"
         rss: 'Activatz los fluxes RSS'
         tagging_rules: 'Escrivètz de règlas per classar automaticament vòstres articles'
@@ -286,7 +291,7 @@ quickstart:
         import: 'Configurar los impòrt'
     first_steps:
         title: 'Primièrs passes'
-        # description: "Now wallabag is well configured, it's time to archive the web. You can click on the top right sign + to add a link."
+        description: "Ara wallabag es ben configurat, es lo moment d'archivar lo web. Podètz clicar sul signe + a man drecha amont per ajustar un ligam."
         new_article: 'Ajustatz vòstre primièr article'
         unread_articles: 'E racaptatz-lo !'
     migrate:
@@ -298,14 +303,14 @@ quickstart:
         readability: 'Migrar dempuèi Readability'
         instapaper: 'Migrar dempuèi Instapaper'
     developer:
-        title: 'Pels desvolopadors'
-        # description: 'We also thought to the developers: Docker, API, translations, etc.'
+        title: 'Pels desvolopaires'
+        description: 'Avèm tanben pensat als desvolopaires : Docker, API, traduccions, etc.'
         create_application: 'Crear vòstra aplicacion tèrça'
-        # use_docker: 'Use Docker to install wallabag'
+        use_docker: 'Utilizar Docker per installar wallabag'
     docs:
         title: 'Documentacion complèta'
-        # description: "There are so much features in wallabag. Don't hesitate to read the manual to know them and to learn how to use them."
-        annotate: 'Anotatar vòstre article'
+        description: "I a un fum de fonccionalitats dins wallabag. Esitetz pas a legir lo manual per las conéisser e aprendre a las utilizar."
+        annotate: 'Anotar vòstre article'
         export: 'Convertissètz vòstres articles en ePub o en PDF'
         search_filters: "Aprenètz a utilizar lo motor de recèrca e los filtres per retrobar l'article que vos interèssa"
         fetching_errors: "Qué far se mon article es pas recuperat coma cal ?"
@@ -390,7 +395,7 @@ developer:
         warn_message_2: "Se suprimissètz un client, totas las aplicacions que l'emplegan foncionaràn pas mai amb vòstre compte wallabag."
         action: 'Suprimir aqueste client'
     client:
-        page_title: 'Desvlopador > Novèl client'
+        page_title: 'Desvolopaire > Novèl client'
         page_description: "Anatz crear un novèl client. Mercés de cumplir l'url de redireccion cap a vòstra aplicacion."
         form:
             name_label: "Nom del client"
@@ -398,7 +403,7 @@ developer:
             save_label: 'Crear un novèl client'
         action_back: 'Retorn'
     client_parameter:
-        page_title: 'Desvolopador > Los paramètres de vòstre client'
+        page_title: 'Desvolopaire > Los paramètres de vòstre client'
         page_description: 'Vaquí los paramètres de vòstre client'
         field_name: 'Nom del client'
         field_id: 'ID Client'
@@ -406,7 +411,7 @@ developer:
         back: 'Retour'
         read_howto: 'Legir "cossí crear ma primièra aplicacion"'
     howto:
-        page_title: 'Desvolopador > Cossí crear ma primièra aplicacion'
+        page_title: 'Desvolopaire > Cossí crear ma primièra aplicacion'
         description:
             paragraph_1: "Las comandas seguentas utilizan la <a href=\"https://github.com/jkbrzt/httpie\">bibliotèca HTTPie</a>. Asseguratz-vos que siasqueòu installadas abans de l'utilizar."
             paragraph_2: "Vos cal un geton per escambiar entre vòstra aplicacion e l'API de wallabar."
@@ -419,31 +424,31 @@ developer:
         back: 'Retorn'
 
 user:
-    # page_title: Users management
-    # new_user: Create a new user
-    # edit_user: Edit an existing user
-    # description: "Here you can manage all users (create, edit and delete)"
-    list:
-    #     actions: Actions
-    #     edit_action: Edit
-    #     yes: Yes
-    #     no: No
-    #     create_new_one: Create a new user
+    page_title: 'Gestion dels utilizaires'
+    new_user: 'Crear un novèl utilizaire'
+    edit_user: 'Modificar un utilizaire existent'
+    description: "Aquí podètz gerir totes los utilizaires (crear, modificar e suprimir)"
+    list:
+         actions: 'Accions'
+         edit_action: 'Modificar'
+         yes: 'Òc'
+         no: 'Non'
+         create_new_one: 'Crear un novèl utilizaire'
     form:
         username_label: "Nom d'utilizaire"
-        # name_label: 'Name'
+        name_label: 'Nom'
         password_label: 'Senhal'
         repeat_new_password_label: 'Confirmatz vòstre novèl senhal'
         plain_password_label: 'Senhal en clar'
         email_label: 'Adreça de corrièl'
-        # enabled_label: 'Enabled'
-        # locked_label: 'Locked'
-        # last_login_label: 'Last login'
-        # twofactor_label: Two factor authentication
-        # save: Save
-        # delete: Delete
-        # delete_confirm: Are you sure?
-        # back_to_list: Back to list
+        enabled_label: 'Actiu'
+        locked_label: 'Varrolhat'
+        last_login_label: 'Darrièra connexion'
+        twofactor_label: 'Autentificacion doble-factor'
+        save: 'Enregistrar'
+        delete: 'Suprimir'
+        delete_confirm: 'Sètz segur ?'
+        back_to_list: 'Tornar a la lista'
 
 flashes:
     config:
@@ -455,7 +460,7 @@ flashes:
             rss_updated: 'La configuracion dels fluxes RSS es ben estada mesa a jorn'
             tagging_rules_updated: 'Règlas misa a jorn'
             tagging_rules_deleted: 'Règla suprimida'
-            user_added: 'Utilizaire "%username%" apondut'
+            user_added: 'Utilizaire "%username%" ajustat'
             rss_token_updated: 'Geton RSS mes a jorn'
     entry:
         notice:
@@ -467,12 +472,12 @@ flashes:
             entry_reloaded_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat"
             entry_archived: 'Article marcat coma legit'
             entry_unarchived: 'Article marcat coma pas legit'
-            entry_starred: 'Article apondut dins los favorits'
+            entry_starred: 'Article ajustat dins los favorits'
             entry_unstarred: 'Article quitat dels favorits'
             entry_deleted: 'Article suprimit'
     tag:
         notice:
-            tag_added: 'Etiqueta aponduda'
+            tag_added: 'Etiqueta ajustada'
     import:
         notice:
             failed: "L'importacion a fracassat, mercés de tornar ensajar"
index 392f9c19456cbaf8a5ec746e82321663b522f789..a2fe13db283ed6ab20c8e3660267bd96db75def1 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Nazwa'
         email_label: 'Adres email'
         twoFactorAuthentication_label: 'Autoryzacja dwuetapowa'
+        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'
index 152d5020dd517b310d4e5d76f46b7ef7377e1ef6..29db9c3e473d088f778b21f328afc7f001d9df7d 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'Nume'
         email_label: 'E-mail'
         # twoFactorAuthentication_label: 'Two factor authentication'
+        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ă'
index a2eca59ba1c8b43f2a7b7e3c5f575ba70e86df8b..41e8e576e8060210c2f5b53ee7024c4c7a32fd13 100644 (file)
@@ -88,6 +88,11 @@ config:
         name_label: 'İsim'
         email_label: 'E-posta'
         twoFactorAuthentication_label: 'İki adımlı doğrulama'
+        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'
index ff7ef73a81509ac971aac10e47061aecc611b9b6..54508b6dcb225f799876d1e418d224fa71ca39f6 100644 (file)
         {{ form_widget(form.user.save) }}
     </form>
 
+    {% if enabled_users > 1 %}
+        <h2>{{ 'config.form_user.delete.title'|trans }}</h2>
+
+        <p>{{ 'config.form_user.delete.description'|trans }}</p>
+        <a href="{{ path('delete_account') }}" onclick="return confirm('{{ 'config.form_user.delete.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red delete-account">
+            {{ 'config.form_user.delete.button'|trans }}
+        </a>
+    {% endif %}
+
     <h2>{{ 'config.tab_menu.password'|trans }}</h2>
 
     {{ form_start(form.pwd) }}
index 270c077f332de577644e574849c7ff7acd7e748e..8434508d0552e3b5c9b3217983a928ca8e2e0b53 100644 (file)
                             {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
                             {{ form_widget(form.user._token) }}
                         </form>
+
+                        {% if enabled_users > 1 %}
+                            <br /><hr /><br />
+
+                            <div class="row">
+                                <h5>{{ 'config.form_user.delete.title'|trans }}</h5>
+                                <p>{{ 'config.form_user.delete.description'|trans }}</p>
+                                <a href="{{ path('delete_account') }}" onclick="return confirm('{{ 'config.form_user.delete.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red delete-account">
+                                    {{ 'config.form_user.delete.button'|trans }}
+                                </a>
+                            </div>
+                        {% endif %}
                     </div>
 
                     <div id="set4" class="col s12">
index 009c4881d0ea8945379e159894f00b4ca51a1f2d..445edb3c1077cb2826e2937cb7fccdff2ae4e2be 100644 (file)
@@ -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 = false')
+            ->getQuery()
+            ->getSingleScalarResult();
+    }
 }
index 1954c654a53fba9f7882d62ad524907fcd6fa069..5faa0130bece27ee59f15b3b0743290f682272cb 100644 (file)
@@ -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
 {
@@ -570,4 +572,122 @@ 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.button', $body[0]);
+
+        $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+
+        $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.button', $body[0]);
+
+        $client->request('GET', '/account/delete');
+        $this->assertEquals(403, $client->getResponse()->getStatusCode());
+
+        $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()
+    {
+        $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');
+        $loggedInUserId = $this->getLoggedInUserId();
+
+        // 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();
+
+        $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->assertNull($user);
+
+        $entries = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findByUser($loggedInUserId);
+
+        $this->assertEmpty($entries);
+    }
 }