luci-base: luci.js: add LuCI.session.getToken()
authorJo-Philipp Wich <jo@mein.io>
Sun, 26 Apr 2020 16:44:48 +0000 (18:44 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 May 2020 17:40:49 +0000 (19:40 +0200)
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 <jo@mein.io>
(cherry picked from commit 551d839f90853b58f81d124c77442009d4df0cb4)

modules/luci-base/htdocs/luci-static/resources/luci.js

index 2b93a728ec685c2fd77d02a4b9f4a2d3b8bc93b3..d890b3a78c0286f85888cacebae52f9af66d1382 100644 (file)
                        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.
                 *