diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-09-08 14:07:36 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-08 13:27:18 +0200 |
commit | bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4 (patch) | |
tree | c9209d37cf5db197e2fa45e7164b55af7a92e374 /src/Wallabag/CoreBundle/Controller | |
parent | abb5291cd5dc98211273e5d3b516a6a0ed8b980f (diff) | |
download | wallabag-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')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 14 |
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; | |||
7 | use Symfony\Component\HttpFoundation\JsonResponse; | 7 | use Symfony\Component\HttpFoundation\JsonResponse; |
8 | use Symfony\Component\HttpFoundation\RedirectResponse; | 8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
9 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
10 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
10 | use Wallabag\CoreBundle\Entity\Config; | 11 | use Wallabag\CoreBundle\Entity\Config; |
11 | use Wallabag\CoreBundle\Entity\TaggingRule; | 12 | use Wallabag\CoreBundle\Entity\TaggingRule; |
12 | use Wallabag\CoreBundle\Form\Type\ConfigType; | 13 | use 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 | ||