Hello, I am trying to implement a system where certain actions require a password entry. The intent is to force the user to enter a password every time certain actions are requested, as a form of confirmation.
Is it possible to hook into the security system or confirmation dialog, such that I can automatically bring up a custom window which does the security validation and performs the action, the way that the default confirmation window does?
Make your own popup window with a password field, then assemble the current username (from the system/client tag, or the system function) and pass it to system.security.validateUser - if it returns True, then you know the password was correct, and can continue your logic.
reqRole = 'Role user must have'
currentUser = system.security.getUsername()
username = usernameField.text
password = passwordField.text
roles = system.security.getUserRoles(username, password)
if roles == None:
# Respond to failed validation.
elif reqRole in roles:
# Respond to successful validation with required role.
pass
# Login validated user if credentials don't match current user.
if username.lower() != currentUser.lower():
# Login user.
system.security.switchUser(username, password)
else:
# Respond to successful validation without required role.
Thanks for your response. How would this work for e.g. a multistate button. I did not have luck using the propertyChange event (I couldn’t stop the ControlValue change)
I assume from your response it’s not possible to override the default confirmation window?