From 551d839f90853b58f81d124c77442009d4df0cb4 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 --- 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 c4f998a406..4b6894c080 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -1846,6 +1846,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.30.2