aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 91cdcae5..abd35c02 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
@@ -251,4 +255,37 @@ class ConfigController extends Controller
251 255
252 return $config; 256 return $config;
253 } 257 }
258
259 /**
260 * Delete account for current user.
261 *
262 * @Route("/account/delete", name="delete_account")
263 *
264 * @param Request $request
265 *
266 * @throws AccessDeniedHttpException
267 *
268 * @return \Symfony\Component\HttpFoundation\RedirectResponse
269 */
270 public function deleteAccountAction(Request $request)
271 {
272 $enabledUsers = $this->getDoctrine()
273 ->getRepository('WallabagUserBundle:User')
274 ->getSumEnabledUsers();
275
276 if ($enabledUsers <= 1) {
277 throw new AccessDeniedHttpException();
278 }
279
280 $user = $this->getUser();
281
282 // logout current user
283 $this->get('security.token_storage')->setToken(null);
284 $request->getSession()->invalidate();
285
286 $em = $this->get('fos_user.user_manager');
287 $em->deleteUser($user);
288
289 return $this->redirect($this->generateUrl('fos_user_security_login'));
290 }
254} 291}