From e4b46f77ef2984b33f4dff0efea0585c7ab0cfbf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 26 Jun 2016 13:36:53 +0200 Subject: work --- .../CoreBundle/Controller/ConfigController.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 91cdcae5..0a306d57 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')); + } } -- cgit v1.2.3 From abb5291cd5dc98211273e5d3b516a6a0ed8b980f Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 1 Jul 2016 10:58:15 +0200 Subject: CS --- src/Wallabag/CoreBundle/Controller/ConfigController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 0a306d57..3cafd1bc 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'); -- cgit v1.2.3 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: Added check if there is only one user Added translations and documentation --- src/Wallabag/CoreBundle/Controller/ConfigController.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Wallabag/CoreBundle/Controller') 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; 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()); -- cgit v1.2.3 From eed812afd0626697d33f7e9d3bfd8eca138c463d Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 19:39:12 +0200 Subject: Logout user before deleting it And add a smal description --- .../CoreBundle/Controller/ConfigController.php | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 70a641f7..662da2a0 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(); - - if ($enabledUsers <= 1) { - throw new AccessDeniedHttpException(); - } - - $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')); - } + 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')); + } } -- cgit v1.2.3 From 7ac3e575f1285a07987346461cee9445ac8c0b3b Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 20:35:16 +0200 Subject: CS --- .../CoreBundle/Controller/ConfigController.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 662da2a0..abd35c02 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() -- cgit v1.2.3