From c4bf12aadee9e1f757fd9d783b034bb57b03fb17 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 5 Jun 2019 17:55:13 +0200 Subject: Add ability to revoke feed token --- .../CoreBundle/Controller/ConfigController.php | 28 ++++++++++++++++++++++ .../Resources/translations/messages.da.yml | 2 ++ .../Resources/translations/messages.de.yml | 2 ++ .../Resources/translations/messages.en.yml | 2 ++ .../Resources/translations/messages.es.yml | 2 ++ .../Resources/translations/messages.fa.yml | 2 ++ .../Resources/translations/messages.fr.yml | 2 ++ .../Resources/translations/messages.it.yml | 2 ++ .../Resources/translations/messages.oc.yml | 2 ++ .../Resources/translations/messages.pl.yml | 2 ++ .../Resources/translations/messages.pt.yml | 2 ++ .../Resources/translations/messages.ro.yml | 2 ++ .../Resources/translations/messages.ru.yml | 2 ++ .../Resources/translations/messages.th.yml | 2 ++ .../Resources/translations/messages.tr.yml | 1 + .../views/themes/baggy/Config/index.html.twig | 16 ++++++------- .../views/themes/material/Config/index.html.twig | 9 +++---- .../CoreBundle/Controller/ConfigControllerTest.php | 18 +++++++++++++- 18 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 3b281d48..cea41303 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -299,6 +299,34 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config') . '#set2'); } + /** + * @param Request $request + * + * @Route("/revoke-token", name="revoke_token") + * + * @return RedirectResponse|JsonResponse + */ + public function revokeTokenAction(Request $request) + { + $config = $this->getConfig(); + $config->setFeedToken(null); + + $em = $this->getDoctrine()->getManager(); + $em->persist($config); + $em->flush(); + + if ($request->isXmlHttpRequest()) { + return new JsonResponse(); + } + + $this->addFlash( + 'notice', + 'flashes.config.notice.feed_token_revoked' + ); + + return $this->redirect($this->generateUrl('config') . '#set2'); + } + /** * Deletes a tagging rule and redirect to the config homepage. * diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index e04c2ff1..330b2755 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -91,6 +91,7 @@ config: no_token: 'Intet token' token_create: 'Opret token' token_reset: 'Nulstil token' + # token_revoke: 'Revoke the token' feed_links: 'RSS-Links' feed_link: unread: 'Ulæst' @@ -593,6 +594,7 @@ flashes: # tagging_rules_updated: 'Tagging rules updated' # tagging_rules_deleted: 'Tagging rule deleted' # feed_token_updated: 'RSS token updated' + # feed_token_revoked: 'RSS token revoked' # annotations_reset: Annotations reset # tags_reset: Tags reset # entries_reset: Entries reset diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 5a9668a9..6f81dc9a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -91,6 +91,7 @@ config: no_token: 'Kein Token' token_create: 'Token erstellen' token_reset: 'Token zurücksetzen' + # token_revoke: 'Revoke the token' feed_links: 'RSS-Links' feed_link: unread: 'Ungelesene' @@ -584,6 +585,7 @@ flashes: tagging_rules_updated: 'Tagging-Regeln aktualisiert' tagging_rules_deleted: 'Tagging-Regel gelöscht' feed_token_updated: 'RSS-Token aktualisiert' + # feed_token_revoked: 'RSS token revoked' annotations_reset: Anmerkungen zurücksetzen tags_reset: Tags zurücksetzen entries_reset: Einträge zurücksetzen diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index e2994f53..8533f82a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -91,6 +91,7 @@ config: no_token: 'No token' token_create: 'Create your token' token_reset: 'Regenerate your token' + token_revoke: 'Revoke the token' feed_links: 'Feed links' feed_link: unread: 'Unread' @@ -593,6 +594,7 @@ flashes: tagging_rules_updated: 'Tagging rules updated' tagging_rules_deleted: 'Tagging rule deleted' feed_token_updated: 'Feed token updated' + feed_token_revoked: 'RSS token revoked' annotations_reset: Annotations reset tags_reset: Tags reset entries_reset: Entries reset diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index d1ccfc81..51f3d69d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -91,6 +91,7 @@ config: no_token: 'Sin token' token_create: 'Crear token' token_reset: 'Reiniciar token' + # token_revoke: 'Revoke the token' feed_links: 'URLs de feeds RSS' feed_link: unread: 'sin leer' @@ -593,6 +594,7 @@ flashes: tagging_rules_updated: 'Regla de etiquetado actualizada' tagging_rules_deleted: 'Regla de etiquetado eliminada' feed_token_updated: 'Token RSS actualizado' + # feed_token_revoked: 'RSS token revoked' annotations_reset: Anotaciones reiniciadas tags_reset: Etiquetas reiniciadas entries_reset: Artículos reiniciados diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index e5d36bd3..6a9cd09b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -91,6 +91,7 @@ config: no_token: 'بدون کد' token_create: 'کد خود را بسازید' token_reset: 'بازنشانی کد' + # token_revoke: 'Revoke the token' feed_links: 'پیوند آر-اس-اس' feed_link: unread: 'خوانده‌نشده' @@ -593,6 +594,7 @@ flashes: tagging_rules_updated: 'برچسب‌گذاری خودکار به‌روز شد' tagging_rules_deleted: 'قانون برچسب‌گذاری پاک شد' feed_token_updated: 'کد آر-اس-اس به‌روز شد' + # feed_token_revoked: 'RSS token revoked' # annotations_reset: Annotations reset # tags_reset: Tags reset # entries_reset: Entries reset diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 0b1853a4..0367ec48 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -91,6 +91,7 @@ config: no_token: "Aucun jeton généré" token_create: "Créez votre jeton" token_reset: "Réinitialisez votre jeton" + token_revoke: 'Supprimer le jeton' feed_links: "Adresses de vos flux" feed_link: unread: "Non lus" @@ -594,6 +595,7 @@ flashes: tagging_rules_updated: "Règles mises à jour" tagging_rules_deleted: "Règle supprimée" feed_token_updated: "Jeton des flux mis à jour" + feed_token_revoked: 'Jeton des flux supprimé' annotations_reset: "Annotations supprimées" tags_reset: "Tags supprimés" entries_reset: "Articles supprimés" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 0474d2bc..02a6145c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -91,6 +91,7 @@ config: no_token: 'Nessun token' token_create: 'Crea il tuo token' token_reset: 'Rigenera il tuo token' + # token_revoke: 'Revoke the token' feed_links: 'Collegamenti RSS' feed_link: unread: 'Non letti' @@ -592,6 +593,7 @@ flashes: tagging_rules_updated: 'Regole di etichettatura aggiornate' tagging_rules_deleted: 'Regola di etichettatura eliminate' feed_token_updated: 'RSS token aggiornato' + # feed_token_revoked: 'RSS token revoked' annotations_reset: Reset annotazioni tags_reset: Reset etichette entries_reset: Reset articoli diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index e761832e..aadc8358 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -91,6 +91,7 @@ config: no_token: 'Pas cap de geton generat' token_create: 'Creatz vòstre geton' token_reset: 'Reïnicializatz vòstre geton' + # token_revoke: 'Revoke the token' feed_links: 'URLs de vòstres fluxes RSS' feed_link: unread: 'Pas legits' @@ -592,6 +593,7 @@ flashes: tagging_rules_updated: 'Règlas misa a jorn' tagging_rules_deleted: 'Règla suprimida' feed_token_updated: 'Geton RSS mes a jorn' + # feed_token_revoked: 'RSS token revoked' annotations_reset: Anotacions levadas tags_reset: Etiquetas levadas entries_reset: Articles levats diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index f3d506e5..780251d8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -91,6 +91,7 @@ config: no_token: 'Brak tokena' token_create: 'Stwórz tokena' token_reset: 'Zresetuj swojego tokena' + # token_revoke: 'Revoke the token' feed_links: 'RSS links' feed_link: unread: 'Nieprzeczytane' @@ -592,6 +593,7 @@ flashes: tagging_rules_updated: 'Reguły tagowania zaktualizowane' tagging_rules_deleted: 'Reguła tagowania usunięta' feed_token_updated: 'Token kanału RSS zaktualizowany' + # feed_token_revoked: 'RSS token revoked' annotations_reset: Zresetuj adnotacje tags_reset: Zresetuj tagi entries_reset: Zresetuj wpisy diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 6ddc1fc1..e811c821 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -91,6 +91,7 @@ config: no_token: 'Nenhum Token' token_create: 'Criar seu token' token_reset: 'Gerar novamente seu token' + # token_revoke: 'Revoke the token' feed_links: 'Links RSS' feed_link: unread: 'Não lido' @@ -592,6 +593,7 @@ flashes: tagging_rules_updated: 'Regras de tags atualizadas' tagging_rules_deleted: 'Regra de tag apagada' feed_token_updated: 'Token RSS atualizado' + # feed_token_revoked: 'RSS token revoked' # annotations_reset: Annotations reset # tags_reset: Tags reset # entries_reset: Entries reset diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 8c0791f0..4e2067d3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -91,6 +91,7 @@ config: no_token: 'Fără token' token_create: 'Crează-ți token' token_reset: 'Resetează-ți token-ul' + # token_revoke: 'Revoke the token' feed_links: 'Link-uri RSS' feed_link: unread: 'Unread' @@ -592,6 +593,7 @@ flashes: # tagging_rules_updated: 'Tagging rules updated' # tagging_rules_deleted: 'Tagging rule deleted' # feed_token_updated: 'RSS token updated' + # feed_token_revoked: 'RSS token revoked' # annotations_reset: Annotations reset # tags_reset: Tags reset # entries_reset: Entries reset diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml index 2ee2d83a..d1040a6b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml @@ -89,6 +89,7 @@ config: no_token: 'Ключ не задан' token_create: 'Создать ключ' token_reset: 'Пересоздать ключ' + # token_revoke: 'Revoke the token' feed_links: 'ссылка на RSS' feed_link: unread: 'непрочитанные' @@ -558,6 +559,7 @@ flashes: tagging_rules_updated: 'Правила тегировния обновлены' tagging_rules_deleted: 'Правила тегировния удалены' feed_token_updated: 'RSS ключ обновлен' + # feed_token_revoked: 'RSS token revoked' annotations_reset: "Аннотации сброшены" tags_reset: "Теги сброшены" entries_reset: "Записи сброшены" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml index 967ae427..bf2bd1f5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml @@ -91,6 +91,7 @@ config: no_token: 'ไม่มีเครื่องหมาย' token_create: 'สร้างเครื่องหมาย' token_reset: 'ทำเครื่องหมาย' + # token_revoke: 'Revoke the token' feed_links: 'ลิงค์ RSS' feed_link: unread: 'ยังไมได้่อ่าน' @@ -590,6 +591,7 @@ flashes: tagging_rules_updated: 'อัปเดตการแท็กข้อบังคับ' tagging_rules_deleted: 'การลบข้อบังคับของแท็ก' feed_token_updated: 'อัปเดตเครื่องหมาย RSS ' + # feed_token_revoked: 'RSS token revoked' annotations_reset: รีเซ็ตหมายเหตุ tags_reset: รีเซ็ตแท็ก entries_reset: รีเซ็ตรายการ diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 2f86f25d..93fb6ca1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -91,6 +91,7 @@ config: no_token: 'Belirteç (token) yok' token_create: 'Yeni belirteç (token) oluştur' token_reset: 'Belirteci (token) sıfırla' + # token_revoke: 'Revoke the token' feed_links: 'RSS akış bağlantıları' feed_link: unread: 'Okunmayan' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 4ef6ab3c..a1caf242 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -111,14 +111,14 @@ {% else %} {{ 'config.form_feed.no_token'|trans }} {% endif %} - – - - {% if feed.token %} - {{ 'config.form_feed.token_reset'|trans }} - {% else %} - {{ 'config.form_feed.token_create'|trans }} - {% endif %} - + + {% if feed.token %} + – {{ 'config.form_feed.token_reset'|trans }} + – {{ 'config.form_feed.token_revoke'|trans }} + {% else %} + – {{ 'config.form_feed.token_create'|trans }} + {% endif %} + 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 818fc4e7..a48c9e28 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 @@ -140,12 +140,13 @@ {% else %} {{ 'config.form_feed.no_token'|trans }} {% endif %} - – + {% if feed.token %} - {{ 'config.form_feed.token_reset'|trans }} + – {{ 'config.form_feed.token_reset'|trans }} + – {{ 'config.form_feed.token_revoke'|trans }} {% else %} - {{ 'config.form_feed.token_create'|trans }} - {% endif %} + – {{ 'config.form_feed.token_create'|trans }} + {% endif %} diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index d8478ce3..b9e0bed2 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -330,7 +330,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertNotContains('config.form_feed.no_token', $body[0]); + $this->assertContains('config.form_feed.token_reset', $body[0]); } public function testGenerateTokenAjax() @@ -351,6 +351,22 @@ class ConfigControllerTest extends WallabagCoreTestCase $this->assertArrayHasKey('token', $content); } + public function testRevokeTokenAjax() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $client->request( + 'GET', + '/revoke-token', + [], + [], + ['HTTP_X-Requested-With' => 'XMLHttpRequest'] + ); + + $this->assertSame(200, $client->getResponse()->getStatusCode()); + } + public function testFeedUpdate() { $this->logInAs('admin'); -- cgit v1.2.3