aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-08 19:39:12 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-08 19:39:12 +0200
commiteed812afd0626697d33f7e9d3bfd8eca138c463d (patch)
tree824080ff56b8cdf1ae0fe5a9413afcc5e8479152 /src
parentc3396c65ef8532091614ec9ae298ba124d58b2b9 (diff)
downloadwallabag-eed812afd0626697d33f7e9d3bfd8eca138c463d.tar.gz
wallabag-eed812afd0626697d33f7e9d3bfd8eca138c463d.tar.zst
wallabag-eed812afd0626697d33f7e9d3bfd8eca138c463d.zip
Logout user before deleting it
And add a smal description
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php43
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig10
2 files changed, 32 insertions, 21 deletions
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
261 * 261 *
262 * @Route("/account/delete", name="delete_account") 262 * @Route("/account/delete", name="delete_account")
263 * 263 *
264 * @param Request $request
265 *
264 * @throws AccessDeniedHttpException 266 * @throws AccessDeniedHttpException
265 * 267 *
266 * @return \Symfony\Component\HttpFoundation\RedirectResponse 268 * @return \Symfony\Component\HttpFoundation\RedirectResponse
267 */ 269 */
268 public function deleteAccountAction() 270 public function deleteAccountAction(Request $request)
269 { 271 {
270 $enabledUsers = $this->getDoctrine() 272 $enabledUsers = $this->getDoctrine()
271 ->getRepository('WallabagUserBundle:User') 273 ->getRepository('WallabagUserBundle:User')
272 ->getSumEnabledUsers(); 274 ->getSumEnabledUsers();
273 275
274 if ($enabledUsers <= 1) { 276 if ($enabledUsers <= 1) {
275 throw new AccessDeniedHttpException(); 277 throw new AccessDeniedHttpException();
276 } 278 }
277 279
278 $em = $this->get('fos_user.user_manager'); 280 $user = $this->getUser();
279 $em->deleteUser($this->getUser()); 281
280 282 // logout current user
281 $this->get('session')->getFlashBag()->add( 283 $this->get('security.token_storage')->setToken(null);
282 'notice', 284 $request->getSession()->invalidate();
283 'flashes.account.notice.account_deleted' 285
284 ); 286 $em = $this->get('fos_user.user_manager');
285 287 $em->deleteUser($user);
286 return $this->redirect($this->generateUrl('fos_user_security_logout')); 288
287 } 289 return $this->redirect($this->generateUrl('fos_user_security_login'));
290 }
288} 291}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index a8a3f9dc..25d259b8 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -169,7 +169,15 @@
169 </form> 169 </form>
170 170
171 {% if enabled_users > 1 %} 171 {% if enabled_users > 1 %}
172 <a class='btn red delete-account' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a> 172 <br /><hr /><br />
173
174 <div class="row">
175 <h5>{{ 'config.delete.title'|trans }}</h5>
176 <p>{{ 'config.delete.description'|trans }}</p>
177 <a href="{{ path('delete_account') }}" onclick="return confirm('{{ 'config.delete.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red delete-account">
178 {{ 'config.form_user.delete_account' | trans }}
179 </a>
180 </div>
173 {% endif %} 181 {% endif %}
174 </div> 182 </div>
175 183