I found the only way around this is to disable the default registration
and create your own.
 
You can use #set($reg = $xwiki.createUser(false))
To insert a new user once it passes any validation you have checked for.

Also use this to send an email (alert to yourself, confirmation to new
users etc)
#set($dumpMe =
$xwiki.mailsender.sendTextMessage('from_regis...@myxwiki.org',
'to_u...@blahblah.com', 'to_someone_e...@www.com', 'to...@nonono.com',
'New user registration at myxwiki.org', $messageText, null))

Another problem with the default registration is that you can pass all
params in the url (GET) and it will register until you disable the
registration all together.

Ajdin


-----Original Message-----
From: users-boun...@xwiki.org [mailto:users-boun...@xwiki.org] On Behalf
Of Edward Laptop
Sent: 07 July 2009 21:56
To: XWiki Users
Subject: [xwiki-users] where does the actual registration happen?

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
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
 
 
--------------------------------------------------------

NOTICE

This message and any files transmitted with it is intended for the addressee 
only and may contain information that is confidential or privileged. 
Unauthorised use is strictly prohibited. If you are not the addressee, you 
should not read, copy, disclose or otherwise use this message, except for the 
purpose of delivery to the addressee. 

Any views or opinions expressed within this e-mail are those of the author and 
do not necessarily represent those of Coventry University.
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to