Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
billy chan
screen name can not have _ / character or email format
January 13, 2008 10:42 PM
Answer

billy chan

Rank: Junior Member

Posts: 43

Join Date: November 19, 2007

Recent Posts

Hello,
when i import some user accounts, once his screen name have _ / character or his screen name is email address, the liferay will throw exception, and stop import process. Now, i only know one solution is changing the source code "ScreenNameValidator".

Question 1: Why screen name can not have character / _ or can not be email?

Question 2: If i need to use screen name to have these characters, How can i do it if i don't want to changing source code?

Question 3: Will i get any problem , if i changing the "ScreenNameValidator"?

Thanks
Alex Wallace
RE: screen name can not have _ / character or email format
January 14, 2008 10:24 AM
Answer

Alex Wallace

Rank: Liferay Master

Posts: 640

Join Date: November 4, 2007

Recent Posts

you can write your own screen name validator and specify it in portal-ext.properties:

 1
 2
 3  #
 4  # Input a class name that extends
 5  # com.liferay.portal.security.auth.ScreenNameValidator. This class will be
 6  # called to validate user ids.
 7  #
 8  users.screen.name.validator=com.yourcompany.util.ScreenNameValidator
 9  #users.screen.name.validator=com.liferay.portal.security.auth.LiberalScreenNameValidator


At one point I talked about this with some liferay folks and they all agreed that it would be safe to allow _ in screen names...

you could use the already existing

1
2    users.screen.name.validator=com.liferay.portal.security.auth.LiberalScreenNameValidator


The original reason, according to liferay, was due to some backwards compatibility with a legacy naming convension in an ancient unix system...
Roman Hoyenko
RE: screen name can not have _ / character or email format
January 14, 2008 11:37 AM
Answer

Roman Hoyenko

Community Moderator

Rank: Liferay Master

Posts: 868

Join Date: October 8, 2007

Recent Posts

It is easy to do and should not cost you any problems. Here is my custom validator, for example:

 1package xxxxx.api.util;
 2
 3import com.liferay.portal.util.UserIdValidator;
 4
 5import com.liferay.portal.model.User;
 6import com.liferay.util.Validator;
 7
 8public class MyCustomValidator extends UserIdValidator
 9{
10    public boolean validate(String userId, String companyId) {
11        if (Validator.isNull(userId) ||
12                (userId.equalsIgnoreCase("cyrus")) ||
13                (userId.equalsIgnoreCase("postfix")) ||
14                (userId.length() < 6 ) ||
15                (userId.indexOf(User.DEFAULT) != -1))
16        {
17
18                return false;
19            }
20            else {
21                return true;
22            }
23       
24    }
25   
26}


I don't know why cyrus or postfix are not allowed, but I left it there just in case. And I made it to be at least 6 chars long. I don't see why email couldn't be the ID, so I removed this check as well as the check for undescore.
billy chan
RE: screen name can not have _ / character or email format
January 14, 2008 5:56 PM
Answer

billy chan

Rank: Junior Member

Posts: 43

Join Date: November 19, 2007

Recent Posts

Thank all help, i've solved the problem now!
Thanks so much
Thomas Kellerer
RE: screen name can not have _ / character or email format
March 5, 2010 1:26 AM
Answer

Thomas Kellerer

Rank: Expert

Posts: 377

Join Date: June 9, 2008

Recent Posts

This won't help with the / character.

Liferay refuses to support this.

http://issues.liferay.com/browse/LPS-4498
rabel rabel
RE: screen name can not have _ / character or email format
May 6, 2010 1:07 AM
Answer

rabel rabel

Rank: New Member

Posts: 3

Join Date: May 6, 2010

Recent Posts

are there a way to disable the validation?
Renee Talabucon
RE: screen name can not have _ / character or email format
June 28, 2010 3:51 AM
Answer

Renee Talabucon

Rank: Junior Member

Posts: 31

Join Date: March 28, 2010

Recent Posts

Hi!~ Total Liferay newbie here..

I need something similar to this, I think.

Our Liferay login is set to screen name and what I need is to let the screen name start with a capital letter. Liferay saves the screen name to all small letters, regardless if you enter capital letters. (screen names are saved in database table "user_" , column name "screenname")

Anyone have an idea how I can force Liferay to allow screen names starting with a capital letter? emoticon Thanks for your help!~
Udaya Ramakrishnan
RE: screen name can not have _ / character or email format
September 8, 2011 4:33 AM
Answer

Udaya Ramakrishnan

Rank: Junior Member

Posts: 67

Join Date: September 6, 2011

Recent Posts

hi
i am very new to Liferay. i am having a similar requirement. i need to allow white spaces in screen name.
i understand and tried ur code. but it is showing error in console. i created hooks and done everything.
can u tell me the procedure in doing that

thank u

regards
Udaya.R
Andromeda K
RE: screen name can not have _ / character or email format
October 16, 2012 6:30 AM
Answer

Andromeda K

Rank: New Member

Posts: 2

Join Date: September 21, 2012

Recent Posts

Hello Guys,

I'm trying to change screenname validator in a way that it accepts @ character.

So it works if I add the user from the user interface while it doesn't work if I use the method add-user provided by json webservice.

I don't understand how you could change the behavior: http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+Users+and+Screennames#2

If you see the above link after that you validate liferay continues to do the same checks so it's not possible without changing the souce code change the behavior for validationscreenName method in UserServiceLocalImpl or what should I do?

It throws an exception on UserServiceLocalImpl class
Caused by: com.liferay.portal.UserScreenNameException
at com.liferay.portal.service.impl.UserLocalServiceImpl.validateScreenName(UserLocalServiceImpl.java:5747)
at com.liferay.portal.service.impl.UserLocalServiceImpl.validate(UserLocalServiceImpl.java:5526)

in this case while if I try to add user manually it doesn't throw any exception.

In both cases (adding user by json or by interface) it execute my validator returning true!

Thank you guys!
Yogesh Garg
RE: screen name can not have _ / character or email format
October 26, 2012 7:18 AM
Answer

Yogesh Garg

Rank: Junior Member

Posts: 51

Join Date: November 10, 2008

Recent Posts

Hi Andromeda,

I have the similar requirement of using the email address as screenmame. Can you please tell me how you fix the issue to have email can be taken as screennames.

Thanks,
Yogesh.
sri p
RE: screen name can not have _ / character or email format
May 20, 2014 3:07 PM
Answer

sri p

Rank: Junior Member

Posts: 85

Join Date: January 22, 2011

Recent Posts

Yogesh Garg:
Hi Andromeda,

I have the similar requirement of using the email address as screenmame. Can you please tell me how you fix the issue to have email can be taken as screennames.

Thanks,
Yogesh.


Hello there,

Does Email allowed as ScreenName in Liferay ?
If it is not allowed, could some one give an idea how to achieve this?

I appreciate everyone help!

Thanks,
Sri