From: Jo-Philipp Wich Date: Sun, 26 Apr 2020 16:44:48 +0000 (+0200) Subject: luci-base: luci.js: add LuCI.session.getToken() X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=551d839f90853b58f81d124c77442009d4df0cb4;p=project%2Fluci.git 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 --- 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. *