Hi,
On Wed, Jul 15, 2009 at 3:51 PM, Edward Laptop
<edward(a)eldon.gotadsl.co.uk>wrote;wrote:
Well, its great that someone, somewhere has got it to
work!!!
You wrote this
"But as you can see, RegisterAction do not verify captcha, so we cannot
use captcha for validating registrations. But this is very easy to be added,
needs a small patch."
Where does this patch go?
But this requires compiling a new xwiki-core module and installing it inside
WEB-INF/lib. This is bit hard specially if you are not a java developer. I'd
rather wait for 2.0 final release :)
Thanks.
- Asiri
---Original Message-----
*From:* Asiri Rathnayake [mailto:asiri.rathnayake@gmail.com]
*Sent:* 15 July 2009 11:09
*To:* edward(a)eldon.gotadsl.co.uk
*Cc:* XWiki Users
*Subject:* Re: [xwiki-users] about to give in...
Hi,
Ok, I got captcha to work for commenting. I will explain how I did it:
* I could not find any helpful documentation so I went and looked at the
CaptchaPlugin.java class (
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-core/src/main/…
)
* Here I found that you need to have a preference parameter named like
<action>_registered or <action>_anonymous in your XWiki.XWikiPreference
object that defines the captcha mode to be used for validation. Possible
values are "image" and "text"
* Out of curiosity I fired up my local XE, navigated to
http://localhost:8080/xwiki/bin/admin/XWiki/XWikiPreferences and selected
edit->class. I looked for fields that looked like above and found the
following ones:
registration_anonymous : Captcha mode for new registrations
registration_registered: This is weired
edit_anonymous: Captcha mode for unregistered user edits
edit_registered: Captcha mode for registered user edits
comment_anonymous: Captcha mode for unregistered user comments
comment_registered: Captcha mode for registered user comments
These fields have pretty names that doesn't make much sense.
* Then I switched back to object edit mode and inside the
XWiki.XWikiPreferences object I found these fields and set them to "image"
* I don't know how I ended up looking at XWiki::hasCaptcha() method but
anyway I was looking at it after some time. Here I learnt that you need the
"xwiki.plugin.captcha" flag to be set to 1 if your captacha validations to
work.
* Then inside eclipse I did a search for all the references of
XWiki.hasCaptcha() method and leant following actions support captcha:
- CommentAddAction
- EditAction
- PreviewAction
- SaveAction
All of these actions only verify if captcha is enabled and if it validates
correctly. They do not display the captcha images, without that displaying
all of them validates to "true". So this means we need to edit the templates
and display captcha if these actions are to be restricted.
But as you can see, RegisterAction do not verify captcha, so we cannot use
captcha for validating registrations. But this is very easy to be added,
needs a small patch.
* Then I went and located commentsinline.vm and found the section which
displays the comment box:
<code>
#macro(displayCommentForm)
#if($xwiki.hasAccessLevel('comment'))
<form action="$doc.getURL('commentadd')" method="post"
id="AddComment">
<fieldset class="expanded" id="commentform">
<legend>$msg.get('core.viewers.comments.add.title')</legend>
<input type="hidden" name="xredirect"
value="${doc.getURL('view')}#Comments" />
#if($context.user != 'XWiki.XWikiGuest')
<label>$msg.get('core.viewers.comments.add.guestName.prompt')
$xwiki.getUserName($context.user)</label>
<input type="hidden" name="${xCommentClass}_author"
value="$context.user"/>
#else
<label>$msg.get('core.viewers.comments.add.guestName.prompt')
<input type="text" name="${xCommentClass}_author"
value="$msg.get('core.viewers.comments.add.guestName.default')"/></label>
#end
<input type="hidden" name="${xCommentClass}_date"
value=""/>
<input type="hidden" name="${xCommentClass}_replyto"
value="$!{request.replyto}"/>
<div class="commentcontainer">
<label>$msg.get('core.viewers.comments.add.comment.label')</label>
<textarea id='${xCommentClass}_comment' rows='5'
cols="80"
name='${xCommentClass}_comment'></textarea>
</div>
<div>
<span class="buttonwrapper"><input type="submit"
value="$msg.get('core.viewers.comments.add.submit')"
class="button"/></span>
<span class="buttonwrapper"><input
#if("$!{request.replyto}" ==
'') type="reset" #else type="submit" #end
value="$msg.get('core.viewers.comments.add.cancel')"
class="button"
name="action_cancel"/></span>
</div>
</fieldset>
</form>
#end
#end
</code>
I added the captcha display code as bellow:
<code>
#macro(displayCommentForm)
#if($xwiki.hasAccessLevel('comment'))
<form action="$doc.getURL('commentadd')" method="post"
id="AddComment">
<fieldset class="expanded" id="commentform">
<legend>$msg.get('core.viewers.comments.add.title')</legend>
<input type="hidden" name="xredirect"
value="${doc.getURL('view')}#Comments" />
#if($context.user != 'XWiki.XWikiGuest')
<label>$msg.get('core.viewers.comments.add.guestName.prompt')
$xwiki.getUserName($context.user)</label>
<input type="hidden" name="${xCommentClass}_author"
value="$context.user"/>
#else
<label>$msg.get('core.viewers.comments.add.guestName.prompt')
<input type="text" name="${xCommentClass}_author"
value="$msg.get('core.viewers.comments.add.guestName.default')"/></label>
#end
<input type="hidden" name="${xCommentClass}_date"
value=""/>
<input type="hidden" name="${xCommentClass}_replyto"
value="$!{request.replyto}"/>
<div class="commentcontainer">
<label>$msg.get('core.viewers.comments.add.comment.label')</label>
<textarea id='${xCommentClass}_comment' rows='5'
cols="80"
name='${xCommentClass}_comment'></textarea>
</div>
$xwiki.jcaptcha.displayCaptcha("comment", "myclass") ## Here
<div>
<span class="buttonwrapper"><input type="submit"
value="$msg.get('core.viewers.comments.add.submit')"
class="button"/></span>
<span class="buttonwrapper"><input
#if("$!{request.replyto}" ==
'') type="reset" #else type="submit" #end
value="$msg.get('core.viewers.comments.add.cancel')"
class="button"
name="action_cancel"/></span>
</div>
</fieldset>
</form>
#end
#end
</code>
* Restarted xwiki and logged in as a normal user (Admin user does not get
captcha anyway) and voila, I saw captcha display near the comment box. I
tried to post a comment with an invalid captcha input and it failed, but the
failiure was not that visible. Then I tried to post a comment with the
correct captcha input and it worked!!!
This is my experience but I'm not sure when captcha support will be fixed
on xwiki completely.
Thanks.
- Asiri
On Wed, Jul 15, 2009 at 3:02 PM, Edward Laptop <edward(a)eldon.gotadsl.co.uk
wrote:
Thanks for the reply!
I have been on this for ages and ages and ages.
I looked at the links below, and I think I see what you mean. To be
honest, its beyond my understanding.
I have been working with registerinline.vm - I can get the captcha field
to veryify fine. In my page there is variable $reg which appears to be the
key.
Please keep in touch - and I will too. Maybe one of us will crack it
Incidentally I used
http://n2.nabble.com/CAPTCHA-for-comments-and-registration-tp507976p507989.…
as a basis and it seemed to work. Trouble was, its not a full solution. I
contact some people from the thread - but nobody seemed to be able to solve
it fully.
Perhaps there is a bug???
Has anyone got captcha to work on a registration page????????
-----Original Message-----
*From:* Asiri Rathnayake [mailto:asiri.rathnayake@gmail.com]
*Sent:* 15 July 2009 10:17
*To:* edward(a)eldon.gotadsl.co.uk; XWiki Users
*Subject:* Re: [xwiki-users] about to give in...
Hi Edward,
On Wed, Jul 15, 2009 at 12:35 PM, Edward Eldon <
edward(a)eldon.gotadsl.co.uk> wrote:
Hi
I have noticed that there has been more activity in the last couple of
days
... so, here's one last attempt.
I have got to the stage where a captcha field is shown, and the page
(registerinline.vm) displays the correct errors if it isn't filled in
(some
simple if statements)
However, the user is STILL registered even if the captcha is filled in
wrongly.
I think I found the problem. Still, I'm not a captcha expert so please
bear with me.
If you consider the CommentAction (
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-core/src/main/…)
you will see that there is a check for captcha.
That is, if you have displayed captcha somewhere in the comment section,
user will _HAVE_ to provide the correct input otherwise the action will not
complete.
On the other hand take the RegisterAction (
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-core/src/main/…)
There is no captcha verification here at all :)
My guess is this is a bug of xwiki, not you doing something wrong.
Still, don't take my word, try to put captcha somehow into comment area
and see if it works... if it does, we cam make sure that no captcha is
supported for log-in action of xwiki, which needs fixing.
I'm trying to get captcha to work for comment action, I will inform you if
i succeed.
Thanks.
- Asiri
I have searched this news group, experimented and given up ... but if
anyone
can suggest how to stop this my xwiki user would really appreciate it.
Happy to post code if anyone's interested!
thanks - hopefully
Edward
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users