Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Username containing 'space' View modes: 
User avatar
Member
Member
guillaume.marquilly-tv5monde - 11/13/2013 4:12:26 AM
   
Username containing 'space'

Hello!

I noticed that username in Kentico can contain some spaces.

However, I would like to disallow the character 'space' because it is weird for a login, and also we need them for several external features.

Is there a way/workaround to customize the username for the registration step?

Thank you for you help!

Guillaume

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/14/2013 6:33:27 AM
   
RE:Username containing 'space'
You can enter a custom expression in the field validation expression. Navigate to Site Manager>Development>System Tables>User> and in the fields section select UserName and enter your regular expression to not include spaces. Right now it's simply a text field and is coded to look for usernames you specify in the Settings to exclude or ban and duplicates but nothing else.

User avatar
Member
Member
guillaume.marquilly-tv5monde - 11/14/2013 7:32:41 PM
   
RE:Username containing 'space'
Thank you very much FroggEye for your answer!


User avatar
Member
Member
guillaume.marquilly-tv5monde - 11/20/2013 9:31:28 PM
   
RE:Username containing 'space'
Hello again!

So I tried to customize the regular expression inside the username and email fields as adviced, but I always got an error during the validation: "The entered values cannot be saved. Please see the fields below for details."

I tried the following regex:

username:
- ^[a-z0-9_-]{3,16}$
-/^[a-z0-9_-]{3,16}$/

email:
- ^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$
- /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/

Source: http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/

Did someone encounter the same issue?

Thank you !

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/28/2013 2:04:18 AM
   
RE:Username containing 'space'
Hi,

Thank you for your message.

Strange is that Kentico cannot contain space character. I tested it in both 6 and 7 version. Whenever I try to save user with space character I get a validation error that some characters are not valid. Are you changing the user name in CMS Desk -> Administration -> Users? Was your site upgraded from older versions? What is your hotfix?

Ultimately can you try installing a fresh Kentico version on your server and try it also there?

Thank you and kind regards,
Richard Sustek

User avatar
Member
Member
guillaume.marquilly-tv5monde - 11/28/2013 10:41:06 PM
   
RE:Username containing 'space'

Hello Richard,

Initially I noticed that some of my users were registered with a username containing a space.

Well I use the webpart CustomRegistrationForm (because I needed to display and hide some fields) for the registration so this form should be directly linked to the parameters of my fields in System Tables - Users - "Registration Form"

To try to restrict some special characters, I used the field Custom - Authorized characters to set the different characters I want to authorize. I also used the trim function to remove the spaces, because anyway I send a mail with the login after the registration is completed.

However it should have been easier to use a regex, but without success.

My issue is not critical anymore by the way.

I run Kentico 6.0.58 SP1

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/29/2013 3:06:21 AM
   
RE:Username containing 'space'
Hi,

Thank you for providing additional information for me and others.

The regex should work, it may be that there is some mistate in your regex, but Im also not very sure as regex can be quite complicated to make.

However this makes sense -> we are checking for spaces in the code and when you used your custom registration from this might have been skipped. Basically I would recommend to check -> Trim the user input in your custom registration form webpart so that the values are saved correctly without any spaces.

I'm glad to hear it works now.

Kind regards,
Richard Sustek