aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ConfigController.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-09-08 14:07:36 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-08 13:27:18 +0200
commitbb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4 (patch)
treec9209d37cf5db197e2fa45e7164b55af7a92e374 /src/Wallabag/CoreBundle/Controller/ConfigController.php
parentabb5291cd5dc98211273e5d3b516a6a0ed8b980f (diff)
downloadwallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.tar.gz
wallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.tar.zst
wallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.zip
Added check if there is only one user
Added translations and documentation
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 3cafd1bc..70a641f7 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;
7use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
8use Symfony\Component\HttpFoundation\RedirectResponse; 8use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
10use Wallabag\CoreBundle\Entity\Config; 11use Wallabag\CoreBundle\Entity\Config;
11use Wallabag\CoreBundle\Entity\TaggingRule; 12use Wallabag\CoreBundle\Entity\TaggingRule;
12use Wallabag\CoreBundle\Form\Type\ConfigType; 13use Wallabag\CoreBundle\Form\Type\ConfigType;
@@ -148,6 +149,9 @@ class ConfigController extends Controller
148 'token' => $config->getRssToken(), 149 'token' => $config->getRssToken(),
149 ], 150 ],
150 'twofactor_auth' => $this->getParameter('twofactor_auth'), 151 'twofactor_auth' => $this->getParameter('twofactor_auth'),
152 'enabled_users' => $this->getDoctrine()
153 ->getRepository('WallabagUserBundle:User')
154 ->getSumEnabledUsers(),
151 ]); 155 ]);
152 } 156 }
153 157
@@ -257,10 +261,20 @@ class ConfigController extends Controller
257 * 261 *
258 * @Route("/account/delete", name="delete_account") 262 * @Route("/account/delete", name="delete_account")
259 * 263 *
264 * @throws AccessDeniedHttpException
265 *
260 * @return \Symfony\Component\HttpFoundation\RedirectResponse 266 * @return \Symfony\Component\HttpFoundation\RedirectResponse
261 */ 267 */
262 public function deleteAccountAction() 268 public function deleteAccountAction()
263 { 269 {
270 $enabledUsers = $this->getDoctrine()
271 ->getRepository('WallabagUserBundle:User')
272 ->getSumEnabledUsers();
273
274 if ($enabledUsers <= 1) {
275 throw new AccessDeniedHttpException();
276 }
277
264 $em = $this->get('fos_user.user_manager'); 278 $em = $this->get('fos_user.user_manager');
265 $em->deleteUser($this->getUser()); 279 $em->deleteUser($this->getUser());
266 280