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.

User Profile
#1
Is there a way to determine which user has logged on to the LM.
Would like to change the value of an Object to identify which user is logged in, so that various controls can be set to Read-Only depending on which user has logged on.
I have a script that enable and disable objects, so just need the bit to find the user ?
Thanks for help
engineer1 grp.write('1/1/1',1)
engineer2 grp.write('1/1/1',2)
Reply
#2
Hi,

Run this script to create the user.lp inside the user ftp folder:
Code:
-- use this path for request: http://192.168.0.10/user/user.lp
-- make sure to enable password for the user folder in the user access settings otherwise it shows 'anonymous'

dst = '/www/user/user.lp'
io.writefile(dst, [[
<?
   require('apps')
   clientuser = request.username or 'anonymous'
   print(clientuser)
?>
]])
script.disable(_SCRIPTNAME)
Then use this in your custom JS to fetched the logged in user:
Code:
$(function(){
   $.get("/user/user.lp", function(data, status){
      if (status === "success"){
         var currentuser = data.trim()
         if(currentuser === 'admin'){
          // do action for admin
         }else if(currentuser === 'erwin'){
            // do action for erwin
        }
       }
   });
})
BR,

Erwin
Reply
#3
Thank You very much, will give it a try
Reply
#4
In the new FW we can check current user by Globals.user
No need for lp in this case. It will work only in RC2 or the new 2.5.0 for SE

Code:
$(function() {   
      var currentuser = Globals.user
      if(currentuser === 'admin'){
       // do action for admin
      }else if(currentuser === 'erwin'){
       // do action for erwin
      }
});
------------------------------
Ctrl+F5
Reply
#5
Yep, noticed it in the beta, cool (:
Reply
#6
Cool, how can I display the logged in user name on the main Vis page
Reply
#7
write it to the object
------------------------------
Ctrl+F5
Reply
#8
Create a label element, set additional classes to username
Add to Custom JS:
Code:
$(function(){
  $('.username').text(Globals.user);
});
Reply
#9
So easy when you know how.
Thanks again for your continued support
Reply
#10
How can I log the actual user in the "objects log" ?
I want recording the user that had pressed the button.
KNX Advanced Partner + Tutor
Reply
#11
In latest fw it is done out of the box
------------------------------
Ctrl+F5
Reply
#12
ok....now I saw !!
thanks !!
KNX Advanced Partner + Tutor
Reply


Forum Jump: