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.

Password Script and touch
#1
Hi,
I'm trying to make a script that allows users of the LogicMachine to change their password. The problem is that it deactivates the touch associated with each user and I need each one to see their screen.

Any clues?

Thank you in advance

Code:
require('apps')
require('json')
require('socket.http')
require('socket.url')
continua = true
i = 1
users = db:getall('SELECT id, login FROM users')
nombre = event.getvalue()
while users[i] ~= nil and continua == true do
    name = users[i].login
  if name == nombre then
    ide = users[i].id
    j=i
    continua = false
  end
  i = i+1
end

        acl = {
        vis ={}, -- Table with the pages to which the user has access
        schedulers = {},
        trends = {}
        }

log (users[j])
log (ide,j,nombre)
log('log',users[j])
pass= 'Passw123'
data = {
  id = ide,
  name = nombre, -- full name
  login = nombre, -- login
  password = pass, -- password
  password_repeat = pass, -- must match password
  active = true,
  --access_vis = 'P', -- partial access to visualization
  --access_schedulers = '', -- no access to schedulers
-- access_trends = 'P', --F', -- full access to trends
    acces_apps ='P',   
  acces_touch ='F',     
        allow_objects = "",
  homepage = "apps-touch",
acl = json.encode(acl)
}



post = 'data=' .. socket.url.escape(json.encode(data))
res, err = socket.http.request('http://admin:Password1@127.0.0.1/scada-main/users/save', post)
log(res, err, pass)
Reply
#2
Use webrequest library: https://forum.logicmachine.net/showthread.php?tid=4425

Some of the configuration fields are spelled incorrectly (acces_apps/acces_touch) and you set partial access without ACL.

Use browser dev tools (F12) to check which fields/values are sent from the admin UI.
Reply
#3
Hi again,

I have fixed the errors that you had told me and applied the changes and it has worked perfectly. 

Thank you so much  Smile
Reply


Forum Jump: