]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/ConfigController.php
Add ability to revoke feed token
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / ConfigController.php
index 3b281d488ececf68fd0362f1d9ab3a98862cf71f..cea4130317e7ebfea4afc1430534718f7b939642 100644 (file)
@@ -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.
      *