留言板
Not able to validate recaptcha
Hi i have designed a portlet in liferay version 6.2 ga1 in which I implemented reCaptcha functionality
code in view.jsp looks like
code in java file LiferayCaptcha.java file
Everytime i entered some text liferay is giving me "Text verification failed" error msg .Please help me out this problem
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
In Liferay 6.2 create account option also Recaptcha not working
Naresh Reddy Kallamadi,修改在7 年前。
RE: Not able to validate recaptcha
Regular Member 帖子: 120 加入日期: 14-7-9 最近的帖子
Abhinav , I have got same error any solution for it?
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
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