Question

5
Replies
183
Views
MarianeA Member since 2016 72 posts
Murex
Posted: March 13, 2017
Last activity: March 16, 2017
Closed

Retrieve value of captcha from the activity Code-Security.pyGenerateCaptcha

Hello,

Currently in the activity Code-Security.pyGenerateCaptcha, RS: Pega-EndUserUI:07-10-01 we are generating a value for the CAPTCHA and storing it under the property pzCaptchaAnswer as follows:
tools.findPage("pxRequestor").putString("pzCaptchaAnswer",captcha.getAnswer());

Also, the HTML rule @baseclass.Web-Login, RS: Pega-EndUserUI:07-10-25 is calling the above activity
We added a function similar to the current function changeCaptcha() that retrieves the value of the captcha (stored under pzCaptchaAnswer) after generating a new one (PS: for now we are currently retrieving/displaying it only. Later on we need it because we are implementing a client-side captcha validation on a page different then the Login Page). Below is the function that is supposed to retrieve and display the catcha generated from the activity pyGenerateCaptcha

function changeCaptcha2() {
var capAnswer = "a";
var captchaSrc = "<%=captchaURL%>"+"&"+(new Date()).getTime();
document.getElementById("captchaDiv2").style.backgroundImage = "url('"+captchaSrc+"')";
<pega:choose>
<pega:when java='<%= tools.findPage("pxRequestor").getString("pzCaptchaAnswer ") != "aa"%>'>
capAnswer = '<%=tools.findPage("pxRequestor").getString("pzCaptchaAnswer ")%>';
</pega:when>
</pega:choose>
alert(capAnswer);
}

We have traced the activity Code-Security.pyGenerateCaptcha and we have seen that the value of pzCaptchaAnswer is correct

However, the alert box that is supposed to display the value of pzCaptchaAnswer either returns an empty value or returns a different captcha code then the one displayed on the page. We cannot trace what happens in the @baseclass.Web-Login ! If we can, can you please indicate how ?

Is the context of pxRequestor changing?
Is there something we are missing that is preventing the retrieval of the value of pzCaptchaAnswer?

My main question is how can we retrieve/display the value of the captcha generated?

Any help or hint will be greatly appreciated :)

Thank you in advance,
Mariane

***Updated by moderator: Lochan to add Categories***

Security System Administration User Interface
Moderation Team has archived post
Share this page LinkedIn