09.06.2020, 10:25
(This post was last modified: 09.06.2020, 10:27 by Erwin van der Zwart.)
Hi,
Run this script to create the user.lp inside the user ftp folder:
Then use this in your custom JS to fetched the logged in user:
BR,
Erwin
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)
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
}
}
});
})
Erwin