-
- /**
- * 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()
- ->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'));
- }