From 986a52106766e7497322951c2bf3a3cbd0b42bf9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 25 Mar 2017 15:54:18 +0100 Subject: [PATCH] Add an endpoint to refresh the token Useful for AJAX requests which burns the token --- application/Router.php | 6 ++++++ index.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/application/Router.php b/application/Router.php index c9a51912..f6896b1c 100644 --- a/application/Router.php +++ b/application/Router.php @@ -45,6 +45,8 @@ class Router public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin'; + public static $GET_TOKEN = 'token'; + /** * Reproducing renderPage() if hell, to avoid regression. * @@ -142,6 +144,10 @@ public static function findPage($query, $get, $loggedIn) return self::$PAGE_SAVE_PLUGINSADMIN; } + if (startsWith($query, 'do='. self::$GET_TOKEN)) { + return self::$GET_TOKEN; + } + return self::$PAGE_LINKLIST; } } diff --git a/index.php b/index.php index 40539a04..9566fb01 100644 --- a/index.php +++ b/index.php @@ -1582,6 +1582,13 @@ function($a, $b) { return $a['order'] - $b['order']; } exit; } + // Get a fresh token + if ($targetPage == Router::$GET_TOKEN) { + header('Content-Type:text/plain'); + echo getToken($conf); + exit; + } + // -------- Otherwise, simply display search form and links: showLinkList($PAGE, $LINKSDB, $conf, $pluginManager); exit;