...
...
Exercise: User Login and Access to the Object
In this exercise, we will have two usernames called “A” and “B,” but username “B” will not be assigned any permission to compare the behavior between a user with and without permission. Then, you will configure the accessibility of the control functions in the Xpanel project.
Add the first user with username “A” and set the password to “1234”. Then, add the second user with username “B” and set the password to “1234” as well. Usernames “A” and “B” should now appear on the user list.
Add a new permission named “Demo Permission” and add a description as necessary.
Add a group named “Test Group,” then assign user “A” and “Demo Permission” to the group. When finished, exit the Identity and Access Management pop-up window.
Create a digital tag named “ON_OFF” with “BOOL” for Type.
Insert a Switch/Lamp object and click on the object to open the Property Editor pane. Then, assign the “ON_OFF” tag to Value under Lamp Properties.
While in the Property Editor pane for the Switch/Lamp object, in the Actions section, create new action command for the On Press called “ON_OFF Switch” with the action “Toggle Tag Value” and the digital tag “ON_OFF” assigned.
Once the “ON_OFF Switch” action command is created successfully, assign the created action command to the On Press action under the Action section.
In the Permission section, assign “Demo Permission” to the Permissions section under the Property Editor pane. This will allow only a user who has “Demo Permission” assigned to them.
Insert a text object and update “New Text” to “Login.”
Click the “Login” text object to open the Property Editor pane. In the Actions section, create new action command for the On Press called “Click to Login” with the action “Open Login Window” assigned.
Once the “Click to Login” action command is created successfully, assign the created action command to the On Press action under the Action section.
Insert a second text object and update “New Text” to “Logout”.
Click the “Logout” text object to open the Property Editor pane. In the Actions section, create a new script for the On Press called “Click to Logout” with
system.logout()
function in the script.
Once the “Click to Logout” script is created successfully, assign the created script to the On Press action under the Action section.Run the project using a simulator environment and try logging in as user “A.” Then, try toggling the Switch/Lamp object ON/OFF.
Next, log out of user “A” and log back in as user “B.” Then, try toggling the Switch/Lamp object ON/OFF.
...
User “A” should be the only user to be able to toggle the Switch/Lamp ON/OFF since user “A” is the only user with permission to toggle the Switch/Lamp.
...