This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

JS different reactions between 2.8.0 and 2.8.3
#1
Hi all,

I writed this script to open a plan according to a user, and hiding menus if it is not an 'admin' one.

It works fine on a HW2 v2.8.0
It don't works on a SpaceLynk v2.8.3

Code:
// -------------------------------------------------------------------------------------
// Dominique Barboyon (c) 19/03/2024
// -------------------------------------------------------------------------------------
// opens a specific plan according to the user login and hides menus if it's not admin
// 19/03/2024 - v1.0
// -------------------------------------------------------------------------------------
$(function(){
   var xhttp = new XMLHttpRequest();
   xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
         var res = xhttp.responseText;
         res = res.trim();
         var isuser = 0;
         if (typeof(res) !== "undefined" && res !== null){
            if (res == 'lota00'){
               showPlan(3);
               isuser = 1;
            } 
            if (res == 'lotb05'){
               showPlan(19);
               isuser = 1;
            }          
            if (res == 'admin_craft'){
               showPlan(21);
               isuser = 0;
            }
            if (res == 'admin'){
               showPlan(21);
               isuser = 0;
            }           
            if (isuser == 1){       
               $('.menu').hide();
               $('.layers').css('left', 0);
            }
          
         }
       
      }
   };
   xhttp.open("GET", "/user/user.lp", true);
   xhttp.send();
});


So, it seams I have to install "user.lp" on the user directory on my SpaceLynk.

As I can't acces viai FTP (security reason) to the SpaceLynk's customer, I want to try to create it via a Lua scritp as this :

Code:
local f = assert(io.open("user/user.lp", "w"))

f:write("<?", '\n')
f:write("require('apps')", '\n')
f:write("clientuser = request.username or 'anonymous'", '\n')
f:write("print(clientuser)", '\n')
f:write("?>", '\n')

f:close()

Question 1 : what is exactly the path ? "user/user.lp" for example.
Question 2 : Is it necessary to update access rights for user.lp to rw-rw-rw- ?

Thank's in advance !
Reply
#2
You don't need .lp file for this, simply use Globals.user variable.
Reply
#3
Perfect Admin, thank you.
Reply


Forum Jump: