From e28f94bf01544a6474abd88d900c4204a10521dc Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 26 Apr 2020 18:44:48 +0200 Subject: [PATCH] luci-base: luci.js: add LuCI.session.getToken() Since we're already have LuCI.session.getID() we should mirror the same interface for retrieving the session token. Signed-off-by: Jo-Philipp Wich (cherry picked from commit 551d839f90853b58f81d124c77442009d4df0cb4) --- modules/luci-base/htdocs/luci-static/resources/luci.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 2b93a728e..d890b3a78 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -1844,6 +1844,16 @@ return env.sessionid || '00000000000000000000000000000000'; }, + /** + * Retrieve the current session token. + * + * @returns {string|null} + * Returns the current session token or `null` if not logged in. + */ + getToken: function() { + return env.token || null; + }, + /** * Retrieve data from the local session storage. * -- 2.25.1