Email Addresses with Social Logins Uniqueness
===

So over the last couple of days I have been implementing the Facebook and Google OAuth 2 Social Logins for my site.

Everything works great and basically:

- When a user logs in their email address is compared to whats already on DB
- If the email exists the social login is attached to that already existing email and the user logins into their already existing account
- Otherwise a new account is made. (Much like I have noticed it works here)

But here comes the tricky part. Google can have to two domains for emails (cos of the UK thing):

- gmail.com
- googlemail.com

And if the Facebook account was made in `googlemail.com` the Google account (using `gmail`) will not link. Now I have solved the Google to Facebook relation by checking the DB for both `gmail.com` and `googlemail.com` but the problem comes if it is reversed and Facebook is the one who cannot find the address.

I thought I could just add the `gmail.com` and `googlemail.com` check to the facebook login function to check for unqiue email addresses but I am wondering if this might cause a problem I cannot forsee.

Some of the things on my mind are:

- Future compatibility with other APIs etc
- Complexity
- Security? ( I get around this a bit by using the  `verified` flag in the Facebook API )
- Other Email providers that might have the same problems with double email domains pointing to the same account (maybe I would have to write a huge unmantainable list?).

So the question is: is adding a DB clause to find by `gmail.com` and `googlemail.com` to my Facebook login function a bad idea?

Should I just assume `gmail.com` and `googlemail.com` are two separate accounts?

Thanks for your thoughts,