luci-theme-material: do not infer login state from url (#520)
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 22 Oct 2015 19:07:40 +0000 (21:07 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 22 Oct 2015 19:08:22 +0000 (21:08 +0200)
Checking for `;` in the url is no good indicator whether a user is logged in,
instead query the dispatcher and set a `logged-in` CSS class on the `<body>`
element if a session exists.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
themes/luci-theme-material/htdocs/luci-static/material/js/script.js
themes/luci-theme-material/luasrc/view/themes/material/header.htm

index a0f0675..fdd23e8 100755 (executable)
     function getCurrentNodeByUrl() {
         var ret = false;
         var getUrlNode = function (href){
-            var linkPos = href.indexOf(";");
-            if (linkPos == -1){
+            if (!$('body').hasClass('logged-in')){
                 return "login";
             }else{
-                linkPos = href.indexOf("/", linkPos);
+                var linkPos = href.indexOf("/", linkPos);
                 if (linkPos == -1){
                     return "overview";
                 }else{
index 99afc06..153be10 100755 (executable)
     <script src="<%=resource%>/xhr.js"></script>
 </head>
 
-<body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %>">
+<body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>">
 
 <header>
        <div class="container">