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
#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


Messages In This Thread
User Profile - by sjfp - 09.06.2020, 09:51
RE: User Profile - by Erwin van der Zwart - 09.06.2020, 10:25
RE: User Profile - by sjfp - 09.06.2020, 10:34
RE: User Profile - by Daniel - 09.06.2020, 10:58
RE: User Profile - by Erwin van der Zwart - 09.06.2020, 12:27
RE: User Profile - by sjfp - 09.06.2020, 13:16
RE: User Profile - by Daniel - 09.06.2020, 13:19
RE: User Profile - by admin - 09.06.2020, 13:23
RE: User Profile - by sjfp - 09.06.2020, 13:33
RE: User Profile - by toujour - 13.08.2020, 13:07
RE: User Profile - by Daniel - 13.08.2020, 13:09
RE: User Profile - by toujour - 13.08.2020, 13:18

Forum Jump: