Add an endpoint to refresh the token

Useful for AJAX requests which burns the token
This commit is contained in:
ArthurHoaro 2017-03-25 15:54:18 +01:00
parent 8b27824338
commit 986a521067
2 changed files with 13 additions and 0 deletions

View file

@ -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 @@ class Router
return self::$PAGE_SAVE_PLUGINSADMIN;
}
if (startsWith($query, 'do='. self::$GET_TOKEN)) {
return self::$GET_TOKEN;
}
return self::$PAGE_LINKLIST;
}
}

View file

@ -1582,6 +1582,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
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;