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>
Sun, 26 Apr 2020 16:45:58 +0000 (18:45 +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>
modules/luci-base/htdocs/luci-static/resources/luci.js

index c4f998a4067a0727a68c79154e5d0457996eb4bd..4b6894c080f1f1ed41fc74b3463d4af431f93209 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.
                 *