]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added check if there is only one user
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 8 Sep 2016 12:07:36 +0000 (14:07 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 8 Oct 2016 11:27:18 +0000 (13:27 +0200)
Added translations and documentation

17 files changed:
docs/en/user/configuration.rst
docs/fr/user/configuration.rst
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

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 3cafd1bc69708ce11b777bb40d9465aed66f0f6f..70a641f7a2c62be68a013699ca45406325e88d7b 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(),
         ]);
     }
 
@@ -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());
 
index 69bfe7b3b559d15fd62305f7f02d538aecbec4cd..4c412592d94783b4f994a3fff615859fdf99d34a 100644 (file)
@@ -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'
index f4d134428f509349d5e93ab4ea2c4d29d8f6a3d7..99b79bce8f7d3fac0f23e8dfb016f4b88c52d3f2 100644 (file)
@@ -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'
index 6ddb38a0c9dc84d5aeb16bb5f3ac52b470ac2e8a..94144ed485c32f552ccc4c1a9d241b9f12f4cdb2 100644 (file)
@@ -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'
index 05b03938d3f12436e35f60c236f9f594de4a8358..a5e8d72243e9f4682a1175d9647e83a3aaf6c17f 100644 (file)
@@ -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'
index 3a01a8ed5437f6cb6bf73587fe427eaafd6b80a1..4b8d9689a9a7bc62776429caa2f446dcc6b840dd 100644 (file)
@@ -88,6 +88,7 @@ config:
         name_label: 'نام'
         email_label: 'نشانی ایمیل'
         twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای'
+        # delete_account: 'Delete my account'
     form_password:
         old_password_label: 'رمز قدیمی'
         new_password_label: 'رمز تازه'
index 094458363d93cd0410cf5690e6633229a0e8d623..67cd5f0e4e717a3e6fab41d2706991867fffa31a 100644 (file)
@@ -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'
index 93a11aee775f9d496d3d896be964393550cd0f59..55d961f3a47623c7228e1ac2e7e25b274e8c6767 100644 (file)
@@ -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'
index 8cadf9a32f7e4274b3bc221778357819a9f96a1e..5c6b424765cae5b0741a7ad6f4df17a9fcf4a7fe 100644 (file)
@@ -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'
index d392272f006dbb04e689dd83069ab19f78fda0b3..be96642729f002b076a9992ba9a4b9369bf83304 100644 (file)
@@ -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'
index f2bce4428d3e2bc55a80dd23e8e43d2c14bc3f41..1e52cf0b23aac86e08133e673ee7e101f4a1bfc0 100644 (file)
@@ -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ă'
index d2bf050461a0cd3f1ff854a9bc56e4ce2fb1aafe..ef5477e13a27401d8238df6662a5f9dff52e885a 100644 (file)
@@ -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'
index ff7ef73a81509ac971aac10e47061aecc611b9b6..29575272cd84ea4a469518b2893f21b1ae2a6cb2 100644 (file)
 
         {{ form_widget(form.user._token) }}
         {{ form_widget(form.user.save) }}
+        {% if enabled_users > 1 %}
+            <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a>
+        {% endif %}
     </form>
 
     <h2>{{ 'config.tab_menu.password'|trans }}</h2>
index cebde1acdfed5eff20fffb02fdd349543319ae5e..5aa3eabe7ecf6dedf3fe5ad75c5f1abb9a90c8d6 100644 (file)
                             {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
                             {{ form_widget(form.user._token) }}
                         </form>
-                        <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.user.delete_account' | trans }}</a>
+
+                        {% if enabled_users > 1 %}
+                        <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a>
+                        {% endif %}
                     </div>
 
                     <div id="set4" class="col s12">
index 009c4881d0ea8945379e159894f00b4ca51a1f2d..178761e6da32ff4e3f758290f5d72c8688890946 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 = 0')
+            ->getQuery()
+            ->getSingleScalarResult();
+    }
 }