Take the 2-minute tour ×

I have created a public facing website which allows you to login using a username/password, or with Twitter, or with Facebook.

When logging in with Twitter for the first time (for example), a user is created in my database with a nickname matching the Twitter screen name. I want this nickname to always be unique.

The problem is that in some cases a user with that nickname already exists, so the user can't be added. I am unsure as to the accepted approach for this problem, the only solution I can see so far is to ask the user to override their nickname, but this doesn't seem too elegant.

The reason the nickname needs to be unique is not a code issue, but an interface issue, for example there are forums and I want each user to be uniquely identified by their nickname.

Are there any other methods anyone can suggest for dealing with this problem?

Edit: At the request of some of the replies I will clarify an example:

Lets say I have a user named Joe Bloggs who is a member on my website. He is not a member of Twitter or Facebook. His nickname on my site is JoeBloggs.

Then, another Joe Bloggs comes along, and wants to sign in with his Twitter account. His Twitter name is JoeBloggs, so when he signs in with Twitter, my system attempts to automatically set his nickname to JoeBloggs. However, this nickname already exists. What is the normal or best practice in the cases where nicknames like this overlap? The only thing I can think of is to prompt the user to specify a different and unique nickname (just for display on my site).

The reason I ask is that this must be a common issue for sites which let you login via Facebook, Twitter, Yahoo - there must be an overlap in the names which are returned from said websites, so I wondered what the normal process is.

share|improve this question

3 Answers 3

Isn't it the case that of a user with that nickname already exists then your current user already has an account with you? Wouldn't you just want to give them the ability to reclaim that old profile? As in "Hey @tracydower, you're already register on my site. Did you forget your password? You want me to email you a link to reset your password? Do you really need 2 accounts on my website? If so, I need you to pick a different Twitter account."

share|improve this answer
I agree. Twitter account names already unique, so if @abc comes back 6 months later I would assume that it's the same user. –  Eonasdan Jun 5 '12 at 14:02
They may not be a member of twitter. Imagine a random user with no Twitter account has signed up with the name 'Test1'. Then, a guy who has a Twitter account called 'Test1' tries to sign in with Twitter. The problem is associating that new user a unique nickname. Twitter isn't the only login mechanism, that's the problem. –  Oriental Jun 5 '12 at 15:55
you should revise your question to make that clear then. –  Eonasdan Jun 5 '12 at 17:09
I think it's clear in my original question. 'public facing website which allows you to login using a username/password, or with Twitter, or with Facebook'. The key word is 'Or'. Do you have any suggestions now that you understand the question? –  Oriental Jun 6 '12 at 7:31

Could you use the Twitter API to confirm they really are the Twitter ID they say they are, and if no Twitter account, allow them other means to authenticate (Google+, Facebook, LinkedIn, old school username and password)? Allowing users to login with a Twitter ID that they don't own seems like asking for a world of hurt.

share|improve this answer
I don't think you're understanding my question. I have users already, a large database of users, who all have nicknames. I am thinking of allowing Twitter as an ADDITIONAL option for new users to sign up. When they sign up using Twitter, I want to automatically assign their nickname to their Twitter ID. The problem occurs if there is already a user who has that nickname. Nothing I have said would mean allowing users to login via Twitter if they don't own it. –  Oriental Jun 5 '12 at 16:09
I have a very similar situation -- a socially integrated site where users can login with FB, Twitter, LinkedIn, or old fashioned username/password and then later can connect one or more of those accounts. If you could post details as to what your users table looks like, I think I could be helpful. –  Masaryk hdsat Jun 7 '12 at 16:50

Maybe you could try and change the database itself - get a field like 'nickOrigin', allow there values like '[yourSite]', 'twitter', etc., and only allow new entries if no entry with the same nick AND nickOrigin exists. Execute a query to modify existing users to have a nickOrigin of [yourSite], and things should be backwards compatable, or at least I imagine them that way :)

share|improve this answer

Your Answer


