Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-11121

Email field not mandatory even though verification registration is enabled.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 5.2.2
    • Administration
    • Ubuntu 14.04 LTS, Firefox 32.0.3
    • Unknown
    • N/A
    • N/A

    Description

      I currently have our wiki set up to validate new user registration through email:
      Use email Verification: "Yes"
      Authentication Active Check: "Yes"

      However, when new users went to register the email field in the form was not required, allowing registrants to submit the form without inputting an email address. Upon submission the registrant could not enter the validation key normally sent via email to new users, as they did not enter an email address in the form.

      I have a video here showing the behaviour: http://youtu.be/xk0t7Hf3rQY

      I sent a note to the XWiki-users list and received the following...

      It’s easy for you to customize your wiki to make that field required by editing the XWiki.Registration page.

      Actually I’ve just checked quickly that page and I see:

        ## The email address field, regex checked with an email pattern. Mandatory if registration uses email verification
        #set($field =
          {'name' : 'register_email',
            'label' : $services.localization.render('core.register.email'),
            'params' : {
              'type' : 'text',
              'size' : '60'
            },
            'validate' : {
              'regex' : {
                'pattern' : '/^([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})$/',
                'failureMessage' : $services.localization.render('xe.admin.registration.invalidEmail')
              }
            }
          })
        #if($xwiki.getXWikiPreferenceAsInt('use_email_verification', 0) == 1)
          #set($field.validate.mandatory = {'failureMessage' : $services.localization.render('core.validation.required.message')})
        #end
      

      So this indicates that the mail field is actually mandatory when mail verification registration is enabled… thus it should work normally… Not sure why it doesn’t in your case. You should open a jira issue explaining how to reproduce it (your setup).

      Now to make the email field mandatory is simple. Change the content from above with:

        #set($field =
          {'name' : 'register_email',
            'label' : $services.localization.render('core.register.email'),
            'params' : {
              'type' : 'text',
              'size' : '60'
            },
            'validate' : {
              'mandatory' : {
                'failureMessage' : 'Email is mandatory'
              },
              'regex' : {
                'pattern' : '/^([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})$/',
                'failureMessage' : $services.localization.render('xe.admin.registration.invalidEmail')
              }
            }
          })
      

      Make sure you save with a user having programming rights.

      Thanks
      -Vincent

      Looking at my local Registration page (http://wiki.opensource.org/bin/XWiki/Registration), the before and after is:

      h3. Content changes
      
      ... 	... 	@@ -218,20 +218,23 @@
      218 	218 	#set($discard = $fields.add($field))
      219 	219 	##
      220 	220 	## The email address field, regex checked with an email pattern.
      {color:red}
      221 		-#set($field =
      222 		- {'name' : 'register_email',
      223 		- 'label' : $services.localization.render('core.register.email'),
      224 		- 'params' : {
      225 		- 'type' : 'text',
      226 		- 'size' : '60'
      227 		- },
      228 		- 'validate' : {
      229 		- 'regex' : {
      230 		- 'pattern' : '/^([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})$/',
      231 		- 'failureMessage' : 
      {color}
      {color:green}
      $services.localization.render('xe.admin.registration.invalidEmail')
      	221 	+#set($field =
      	222 	+ {'name' : 'register_email',
      	223 	+ 'label' : $services.localization.render('core.register.email'),
      	224 	+ 'params' : {
      	225 	+ 'type' : 'text',
      	226 	+ 'size' : '60'
      	227 	+ },
      	228 	+ 'validate' : {
      	229 	+ 'mandatory' : {
      	230 	+ 'failureMessage' : 'Email is mandatory'
      	231 	+ },
      	232 	+ 'regex' : {
      	233 	+ 'pattern' : '/^([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})$/',
      	234 	+ 'failureMessage' : $services.localization.render('xe.admin.registration.invalidEmail')
      {color}
      	235 	+ }
      232 	232 	}
      {color:red}
      233 		- }
      234 		- })
      {color}
      {color:green}
      	237 	+ })
      {color}
      235 	235 	#set($discard = $fields.add($field))
      236 	236 	##
      237 	237 	#*********
      

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              pmasson Patrick Masson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: