diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 91cdcae50..0a306d57c 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -251,4 +251,24 @@ class ConfigController extends Controller return $config; } + + /** + * Delete account for current user. + * + * @Route("/account/delete", name="delete_account") + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function deleteAccountAction() + { + $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')); + } } diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 2652a1028..69bfe7b3b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -486,3 +486,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index e0f29b611..f4d134428 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Neuer Client erstellt.' client_deleted: 'Client gelöscht' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b8e981129..6ddb38a0c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -485,6 +485,9 @@ flashes: notice: client_created: 'New client %name% created.' client_deleted: 'Client %name% deleted' + account: + notice: + account_deleted: 'Account deleted' user: notice: added: 'User "%username%" added' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 70633bd76..05b03938d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nuevo cliente creado.' client_deleted: 'Cliente suprimido' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 074ab7a89..3a01a8ed5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -485,3 +485,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6d85a5aea..094458363 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nouveau client %name% créé' client_deleted: 'Client %name% supprimé' + account: + notice: + account_deleted: 'Compte supprimé' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 15f7e7743..93a11aee7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nuovo client creato.' client_deleted: 'Client eliminato' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 1d10be2ae..8cadf9a32 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Novèl client creat' client_deleted: 'Client suprimit' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 547e9c8bf..d392272f0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -486,3 +486,6 @@ flashes: notice: client_created: 'Nowy klient utworzony.' client_deleted: 'Klient usunięty' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 2b1d4f6db..f2bce4428 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -486,3 +486,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 8cfc245ab..d2bf05046 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -485,3 +485,6 @@ flashes: notice: # client_created: 'New client created.' # client_deleted: 'Client deleted' + account: + notice: + # account_deleted: 'Account deleted' 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 270c077f3..cebde1acd 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 @@ -167,6 +167,7 @@ {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} {{ form_widget(form.user._token) }} + {{ 'config.user.delete_account' | trans }}
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index d98ae76a5..eb7774cd1 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -25,7 +25,7 @@ use Wallabag\CoreBundle\Entity\Entry; * @UniqueEntity("email") * @UniqueEntity("username") */ -class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface +class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface, \Serializable { /** * @var int @@ -240,4 +240,14 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return false; } + + public function serialize() + { + return serialize($this->id); + } + + public function unserialize($serialized) + { + $this->id = unserialize($serialized); + } }