On 01/26/2010 02:14 AM, cjdelisle (SVN) wrote:
> Author: cjdelisle
> Date: 2010-01-26 02:14:45 +0100 (Tue, 26 Jan 2010)
> New Revision: 26388
>
> Modified:
>
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> Log:
> XAADMINISTRATION-77: Improve registration interface: Fixed embarassing bug
> which made empty captchas be accepted if there was no 'mandatory' constraint
> on captcha.
>
> Modified:
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> ===================================================================
> ---
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> 2010-01-26 00:25:32 UTC (rev 26387)
> +++
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> 2010-01-26 01:14:45 UTC (rev 26388)
You reintroduced the old title:
> -<title>Registration</title>
> +<title>Verified Registration Application</title>
> <template></template>
> <defaultTemplate></defaultTemplate>
> <validationScript></validationScript>
> @@ -377,7 +377,7 @@
> #set($cv = $captchaservice.getCaptchaVerifier('image'))
> #if(!$cv.isAnswerCorrect($cv.getUserId($request), $answer))
> failed
> - #end
> + #end
> #end
> ##
> ## Pass the name of the template to $xwiki.createUser so any contained
> information will be passed in.
> @@ -398,7 +398,7 @@
> #else
> #set($docName = $doc.getName())
> #end
> - #if($xcontext.hasAccessLevel("edit", $docName))
> + #if($xcontext.hasAccessLevel("edit", $doc.getFullName()))
> #set($field =
> {'name' : 'configure',
> 'prompt' : "<a href='$xwiki.getURL($docName,
> 'edit')?editor=wiki'>You can configure this application by clicking
> here.</a>",
> @@ -451,54 +451,53 @@
> #set($fieldName = $field.get('name'))
> #set($validate = $field.get('validate'))
> #set($error = '')
> - #if($request.get($fieldName)&& $request.get($fieldName) != '')
> - #set($value = $request.get($fieldName))
> - ##
> - ## Regex validation
> - #if($validate.get('regex'))
> - #set($regex = $validate.get('regex'))
> - #if($regex.get('pattern')&& $regex.get('failureMessage'))
> - #if(!$xcontext.getUtil().match($regex.get('pattern'), $value))
> - #set($error = $regex.get('failureMessage'))
> - #end
> - #elseif($regex.get('pattern'))
> - ERROR: In field: ${fieldName}: regex validation must include
> failureMessage.
> - #end
> + #set($value = $request.get($fieldName))
> + ##
> + ## Check if content is mandatory
(!$value || $value == '') can be rewritten as ("$!{value}" == '')
> + #if($validate.get('mandatory')&& (!$value || $value == ''))
> + #set($mandatory = $validate.get('mandatory'))
> + #if($mandatory.get('failureMessage'))
> + #set($error = $mandatory.get('failureMessage'))
> + #else
> + ERROR: In field: ${fieldName}: mandatory validation requires a
> failureMessage
> #end
> - ##
> - ## If regex validation passed, check "mustMatch" validation
> - #if($error == ''&& $validate.get('mustMatch'))
> - #set($mustMatch = $validate.get('mustMatch'))
> - #if($mustMatch.get('name')&&
> $mustMatch.get('failureMessage'))
> - #if($request.get($fieldName) !=
> $request.get($mustMatch.get('name')))
> - #set($error = $mustMatch.get('failureMessage'))
> - #end
> - #else
> - ERROR: In field: ${fieldName}: mustMatch validation required
> both name
> - (of field which this field must match) and failureMessage.
> + #end
> + ##
> + ## mustMatch validation
> + #if($error == ''&& $validate.get('mustMatch'))
> + #set($mustMatch = $validate.get('mustMatch'))
> + #if($mustMatch.get('name')&&
> $mustMatch.get('failureMessage'))
> + #if($request.get($fieldName) !=
> $request.get($mustMatch.get('name')))
> + #set($error = $mustMatch.get('failureMessage'))
> #end
> + #else
> + ERROR: In field: ${fieldName}: mustMatch validation required both
> name
> + (of field which this field must match) and failureMessage.
> #end
> - ##
> - ## If regex and mustMatch validation passed, try programmatic
> validation
> - #if($error == ''&& $validate.get('programmaticValidation'))
> - #set($pv = $validate.get('programmaticValidation'))
> - #if($pv.get('code')&& $pv.get('failureMessage'))
> - #set($pvReturn = "#evaluate($pv.get('code'))")
> - #if($pvReturn.indexOf('failed') != -1)
> - #set($error = $pv.get('failureMessage'))
> - #end
> - #else
> - ERROR: In field: ${fieldName}: programmaticValidation requires
> code and failureMessage
> + #end
> + ##
> + ## Regex validation
> + #if($error == ''&& $validate.get('regex'))
> + #set($regex = $validate.get('regex'))
> + #if($regex.get('pattern')&& $regex.get('failureMessage'))
> + #if(!$xcontext.getUtil().match($regex.get('pattern'), $value))
> + #set($error = $regex.get('failureMessage'))
> #end
> + #elseif($regex.get('pattern'))
> + ERROR: In field: ${fieldName}: regex validation must include
> failureMessage.
> #end
> + #end
> ##
> - ## If no content, check if content is mandatory
> - #elseif($validate.get('mandatory'))
> - #set($mandatory = $validate.get('mandatory'))
> - #if($mandatory.get('failureMessage'))
> - #set($error = $mandatory.get('failureMessage'))
> + ## If regex and mustMatch validation passed, try programmatic
> validation
> + #if($error == ''&& $validate.get('programmaticValidation'))
> + #set($pv = $validate.get('programmaticValidation'))
> + #if($pv.get('code')&& $pv.get('failureMessage'))
> + #set($pvReturn = "#evaluate($pv.get('code'))")
> + #if($pvReturn.indexOf('failed') != -1)
> + #set($error = $pv.get('failureMessage'))
> + #end
> #else
> - ERROR: In field: ${fieldName}: mandatory validation requires a
> failureMessage
> + ERROR: In field: ${fieldName}: programmaticValidation requires
> code and failureMessage
> #end
> #end
> #if($error != '')
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs