This is my first blog hope i share something useful.
In personas 3.0 i have created many flavors but i was thinking how to protect it even though it is assigned to some specific users, so I came up with this idea.
I wrote a script and attached to OnLoad event to get the value from the user and check it in the script, If the user enters the correct password the flavor gets displayed if the entered password is incorrect the flavor will be changed so that he cannot access the main flavor.
In order to prevent continuous execution of the script on screen refresh I have placed a text box and defaulted the value to 0 and changed the value to 1 if the entered password is correct, during the script execution first the value of the textbox is checked if its zero and then proceeds further. The code will be like given below.
if(session.findById(“wnd/usr/txtPersonas_1457446845746”).text == “0”) // Check weather the script executes first time or not
var pass = prompt(“Enter the Password…”); // get the password from user
if(pass == “personas”) // check the password
session.findById(“wnd/usr/txtPersonas_1457446845746”).text = “1”; //Change the value in the textbox if password is correct
session.utils.changeFlavor(“0021F60F04171ED5B9ACE21062731D05”); // Change the flavor if the password is incorrect
A textbox prompting the password will be shown. I could not achieve hiding the password entry like “********” yet , I am working on it once i do it i will update this post.
The next is the flavor to which the control changes, we have to customize the flavor with appearance like “blocked” or “not authorized” and give a back button or try again button so that we can reenter the password. On clicking the back button it should take you to the main flavor. I have customized the flavor and it look like this
Hope this was useful post. Thank You.