Dear All
I have inserted a captcha field into our registration page. It validates
correctly. However the user is still registered even if the code is
incorrectly entered.
I have tried to find the part within the code which actaully does the
registering once the fields are correctly filled in. I could then put this
in an if statement which depends on $reg and the captcha field. However I
can't find it.
Please, please, please can someone now just help me finish off.
I attach a short version of the code I have.
## declare the plugin
#set($captchaPlugin = $xwiki.jcaptcha)
##verify captcha
##call the verifyCaptcha
#if($captchaPlugin.verifyCaptcha("edit"))
<h2>captcha correct</h2>
#else
<h2>captcha wrong</h2>
#end
#if(!$reg||$reg<0 )
<p>Welcome ......</p>
#end
#if($reg && $reg<=0)
#if($reg==-2)
#error("$msg.get('core.register.passwordMismatch')")
#elseif($reg==-3)
#error("$msg.get('core.register.userAlreadyExists')")
#elseif($reg==-4)
#error("$msg.get('core.register.invalidUsername')")
#elseif($reg==-8)
#error("$msg.get('core.register.userAlreadyExists')")
#else
#error("$msg.get('core.register.registerFailed', [$reg])")
#end
#elseif($reg)
#set($xwname = "XWiki.${request.xwikiname}")
#info("$msg.get('core.register.successful',
[$xwiki.getUserName($xwname), $request.xwikiname])")
#end
#if(!$reg||$reg<0)
<form id="register" action="verifyCaptcha"
method="post">
<div>
#set($captchaPlugin = $xwiki.jcaptcha)
<input type="hidden" name="template"
value="XWiki.XWikiUserTemplate"
/>
<input type="hidden" name="register"
value="1"/>
#set($class = $xwiki.getClass("XWiki.XWikiUsers"))
#set($obj = $class.newObject())
#set($serverobj = $class.newObject())
#set($discard = $doc.use("XWiki.XWikiUsers"))
#if($request.register_first_name)
$doc.set("first_name", $request.register_first_name)
#end
#if($request.register_last_name)
$doc.set("last_name", $request.register_last_name)
#end
<dl>
##username
<dt>$msg.get("core.register.username")</dt>
<dd><input name="xwikiname" type="text"
size="20" onfocus="
prepareName(document.forms.register);" /></dd>
##password
##lots of form fields here
#if ($captchaPlugin)
$captchaPlugin.displayCaptcha("edit","register_captcha")
#end
<span class="buttonwrapper"><input type="submit"
value="$msg.get("core.register.submit")"/></span></div>
</form>
#end