alpha tested reCAPTCHA v2.
This commit is contained in:
parent
84834ad21a
commit
e99dc24172
|
@ -26,8 +26,7 @@ import javax.mail.internet.InternetAddress;
|
|||
*/
|
||||
public class MailForm extends MVCPortlet {
|
||||
|
||||
@ProcessAction(name = "validateCaptcha")
|
||||
public void validateCaptcha(ActionRequest actionRequest,
|
||||
public void submitSuggestion(ActionRequest actionRequest,
|
||||
ActionResponse actionResponse) throws IOException, PortletException {
|
||||
|
||||
String name = ParamUtil.getString(actionRequest, "name");
|
||||
|
@ -49,16 +48,6 @@ public class MailForm extends MVCPortlet {
|
|||
if (splits.length > 1)
|
||||
emailAddress = "info@"+ hostname.split("www.")[1];
|
||||
}
|
||||
try {
|
||||
/**
|
||||
* This is the actual code which validate captcha data entered by user.
|
||||
*/
|
||||
CaptchaUtil.check(actionRequest);
|
||||
System.out.println("CAPTCHA validated successfully");
|
||||
} catch (CaptchaException e) {
|
||||
e.printStackTrace();
|
||||
SessionErrors.add(actionRequest, "errorMessage");
|
||||
}
|
||||
String bodyTextHTML = "<p>From: " + name + "</p>";
|
||||
bodyTextHTML += "<p>Email: " + email + "</p>";
|
||||
bodyTextHTML += "<p>Message:</p><p> " + message + "</p>";
|
||||
|
@ -83,19 +72,5 @@ public class MailForm extends MVCPortlet {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The below code is responsible for rendering the CAPTCHA image
|
||||
*/
|
||||
@Override
|
||||
public void serveResource(ResourceRequest resourceRequest,
|
||||
ResourceResponse resourceResponse) throws IOException,
|
||||
PortletException {
|
||||
|
||||
try {
|
||||
CaptchaUtil.serveImage(resourceRequest, resourceResponse);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<%@ include file="init.jsp"%>
|
||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||
<!-- This URL will be invoked before showing the CAPTCHA image -->
|
||||
<portlet:resourceURL var="captchaURL" />
|
||||
|
||||
<!-- This URL validate the CAPTCHA data entered by user -->
|
||||
<portlet:actionURL var="validateURL" name="validateCaptcha" />
|
||||
|
||||
<liferay-ui:error key="errorMessage"
|
||||
message="Enter correct data as shown in the image" />
|
||||
<portlet:actionURL var="validateURL" name="submitSuggestion" />
|
||||
|
||||
|
||||
<aui:form action="<%=validateURL%>" method="post" name="fm">
|
||||
|
|
Loading…
Reference in New Issue