mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-27 18:10:28 +00:00
Logout user before deleting it
And add a smal description
This commit is contained in:
parent
c3396c65ef
commit
eed812afd0
2 changed files with 28 additions and 17 deletions
|
@ -261,28 +261,31 @@ class ConfigController extends Controller
|
||||||
*
|
*
|
||||||
* @Route("/account/delete", name="delete_account")
|
* @Route("/account/delete", name="delete_account")
|
||||||
*
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
* @throws AccessDeniedHttpException
|
* @throws AccessDeniedHttpException
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function deleteAccountAction()
|
public function deleteAccountAction(Request $request)
|
||||||
{
|
{
|
||||||
$enabledUsers = $this->getDoctrine()
|
$enabledUsers = $this->getDoctrine()
|
||||||
->getRepository('WallabagUserBundle:User')
|
->getRepository('WallabagUserBundle:User')
|
||||||
->getSumEnabledUsers();
|
->getSumEnabledUsers();
|
||||||
|
|
||||||
if ($enabledUsers <= 1) {
|
if ($enabledUsers <= 1) {
|
||||||
throw new AccessDeniedHttpException();
|
throw new AccessDeniedHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = $this->get('fos_user.user_manager');
|
$user = $this->getUser();
|
||||||
$em->deleteUser($this->getUser());
|
|
||||||
|
|
||||||
$this->get('session')->getFlashBag()->add(
|
// logout current user
|
||||||
'notice',
|
$this->get('security.token_storage')->setToken(null);
|
||||||
'flashes.account.notice.account_deleted'
|
$request->getSession()->invalidate();
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('fos_user_security_logout'));
|
$em = $this->get('fos_user.user_manager');
|
||||||
}
|
$em->deleteUser($user);
|
||||||
|
|
||||||
|
return $this->redirect($this->generateUrl('fos_user_security_login'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,15 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% if enabled_users > 1 %}
|
{% if enabled_users > 1 %}
|
||||||
<a class='btn red delete-account' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a>
|
<br /><hr /><br />
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<h5>{{ 'config.delete.title'|trans }}</h5>
|
||||||
|
<p>{{ 'config.delete.description'|trans }}</p>
|
||||||
|
<a href="{{ path('delete_account') }}" onclick="return confirm('{{ 'config.delete.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red delete-account">
|
||||||
|
{{ 'config.form_user.delete_account' | trans }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue