Fórum

How to implement captcha in 6.0 EE?

bo li, modificado 12 Anos atrás.

How to implement captcha in 6.0 EE?

Junior Member Postagens: 38 Data de Entrada: 14/11/11 Postagens Recentes
Anyone can gieve a solution about How to implement captcha in 6.0 EE?

Thanks!
thumbnail
Danial Mustofa Habibi, modificado 12 Anos atrás.

RE: How to implement captcha in 6.0 EE?

Regular Member Postagens: 141 Data de Entrada: 01/11/11 Postagens Recentes
bo li:
Anyone can gieve a solution about How to implement captcha in 6.0 EE?

Thanks!



I'm never tried EE but in CE I'm using this method in my porlet class
@Override
	public void serveResource(ResourceRequest resourceRequest,
			ResourceResponse resourceResponse) throws IOException,
			PortletException {
		try {
			com.liferay.portal.kernel.captcha.CaptchaUtil.serveImage(
					resourceRequest, resourceResponse);
		} catch (Exception e) {
			log.error(e);
		}
	}


and this one for validate the captcha
private static String getCaptchaValueFromSession(PortletSession session) {
		Enumeration<string> atNames = session.getAttributeNames();
		while (atNames.hasMoreElements()) {
			String name = atNames.nextElement();
			if (name.contains("CAPTCHA_TEXT")) {
				return (String) session.getAttribute(name);
			}
		}
		return null;
	}</string>


in your jsp just use this tag
		<liferay-ui:error key="Invalid-captcha" message="Invalid-captcha"></liferay-ui:error>
			<portlet:resourceurl var="captchaURL" />
			<liferay-ui:captcha url="<%= captchaURL %>" />

if you want to use google captcha , go to control panel then to server administration -->catcha

regards

Danial