]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/ConfigController.php
Logout user before deleting it
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / ConfigController.php
index 70a641f7a2c62be68a013699ca45406325e88d7b..662da2a0887853da6f8aa31b6b149e8852487fa9 100644 (file)
@@ -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'));
+    }
 }