Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How Can I Password Protect An Image Field

Avatar

Level 3

Is there a trick that you know of to password protect an image field?

I have an image field, Only few directors allowed to use it.I want to restrict others from using it.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

I put a button beside the image field that teh user can click to activate it. On the Initialize event of the Image field set the access to "readOnly" (ImageField1.access = "readOnly". Then on the click event of the button use code like this:

var pswd = app.response("This image is protected by a password. \n Please enter a valid password.");

if  (pswd == "password"){

   ImageField1.access

= "";

} else

{

     app.alert("You entered an invalid password!")

}

Paul

View solution in original post

4 Replies

Avatar

Level 10

Hide and show based on the assigned user field . Do you think it won't work?

Nith

Avatar

Level 3

I don't like to use hide and unhide. I was thinking of adding a field called password. If someone clicks on the image field then I wanted the program to request a password. Or to make the image field protected or Read only unless a password was entered. The password I'll give it to them verbally.

Assume they must type PASS12345. Then when they type it will change the attribute on the image field. I know the concepte but not how to write it.

Avatar

Correct answer by
Former Community Member

I put a button beside the image field that teh user can click to activate it. On the Initialize event of the Image field set the access to "readOnly" (ImageField1.access = "readOnly". Then on the click event of the button use code like this:

var pswd = app.response("This image is protected by a password. \n Please enter a valid password.");

if  (pswd == "password"){

   ImageField1.access

= "";

} else

{

     app.alert("You entered an invalid password!")

}

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----