Foros de discusión

Not able to validate recaptcha

Abhinav Manohar, modificado hace 10 años.

Not able to validate recaptcha

New Member Mensajes: 4 Fecha de incorporación: 28/04/14 Mensajes recientes
Hi i have designed a portlet in liferay version 6.2 ga1 in which I implemented reCaptcha functionality
code in view.jsp looks like

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<%@page import="com.liferay.portal.kernel.captcha.CaptchaTextException"%>
<%@page import="com.liferay.portal.kernel.captcha.CaptchaMaxChallengesException"%>

<liferay-ui:error exception="<%= CaptchaTextException.class %>" message="text-verification-failed" />
<liferay-ui:error exception="<%= CaptchaMaxChallengesException.class %>" message="maximum-number-of-captcha-attempts-exceeded" />
<portlet:actionurl var="testCaptchaActionURL" name="testCaptcha">
</portlet:actionurl>
<aui:form action="<%= testCaptchaActionURL %>" method="post" name="fm">
<aui:input name="firstName" value="" />
<aui:input name="lastName" value="" />
<portlet:resourceurl var="captchaURL">
</portlet:resourceurl>
<liferay-ui:captcha url="<%=captchaURL%>" />
<aui:button-row>
<aui:button type="submit" />
</aui:button-row>
</aui:form>


code in java file LiferayCaptcha.java file

public void testCaptcha(ActionRequest actionRequest, ActionResponse actionResponse)throws IOException, PortletException {
	String firstName=ParamUtil.getString(actionRequest,"firstName");
	String lastName=ParamUtil.getString(actionRequest,"lastName");
	System.out.println("firstName::"+firstName);
	System.out.println("lastName::"+lastName);
	System.out.println(com.liferay.portal.kernel.captcha.CaptchaUtil.getCaptcha());
	System.out.println(actionRequest.getPortletSession().getAttributeNames());
	
	try{
		com.liferay.portal.kernel.captcha.CaptchaUtil.getCaptcha().check(actionRequest);
		System.out.println("after getcaptcha");
		com.liferay.portal.kernel.captcha.CaptchaUtil.check(actionRequest);
	System.out.println("Success");
	}catch(Exception e){
		if (e instanceof CaptchaTextException || e instanceof CaptchaMaxChallengesException ){
			SessionErrors.add(actionRequest, e.getClass(), e);
			
		}else{
			System.out.println("Captcha verification success::");
		}
		
	}
}

Everytime i entered some text liferay is giving me "Text verification failed" error msg .Please help me out this problem
Abhinav Manohar, modificado hace 10 años.

RE: Not able to validate recaptcha

New Member Mensajes: 4 Fecha de incorporación: 28/04/14 Mensajes recientes
In Liferay 6.2 create account option also Recaptcha not working
thumbnail
Naresh Reddy Kallamadi, modificado hace 7 años.

RE: Not able to validate recaptcha

Regular Member Mensajes: 120 Fecha de incorporación: 9/07/14 Mensajes recientes
Abhinav , I have got same error any solution for it?
Santiago Llull, modificado hace 6 años.

RE: Not able to validate recaptcha

New Member Mensaje: 1 Fecha de incorporación: 20/09/17 Mensajes recientes
You are doing doble checking

com.liferay.portal.kernel.captcha.CaptchaUtil.getCaptcha().check(actionRequest);
System.out.println("after getcaptcha");
com.liferay.portal.kernel.captcha.CaptchaUtil.check(actionRequest);

the second time the captcha return error, code must be:

Captcha c = com.liferay.portal.kernel.captcha.CaptchaUtil.getCaptcha()
c.check(actionRequest);

or

com.liferay.portal.kernel.captcha.CaptchaUtil.getCaptcha().check(actionRequest);

Regards