# We are implementing custom login; if a user creates an account and then logins with a social account (and viceversa) how do we recognize its the same user?

**URL:** <https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326>\
**Category:** Get Help\
**Tags:** linking, social-connections\
**Created:** [September 28, 2017, 12:54pm UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326 "2017-09-28T12:54:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![info24](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@info24](https://community.auth0.com/u/info24)\
**Post date:** [September 28, 2017, 12:54pm UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326/1 "2017-09-28T12:54:49Z")

</div>

We are implementing custom login; if a user creates an account and then logins with a social account how do we recognize its the same user? Same question if the user first logins with a social account and they attempts to create a user profile. Can it be always detected and what are best practices to handle this?  
Thank you

---

<div class="post-metadata">

**Author:** ![Mark\_Redman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark_redman/32/6240_2.png) [@Mark\_Redman](https://community.auth0.com/u/Mark_Redman)\
**Post date:** [September 28, 2017, 1:57pm UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326/2 "2017-09-28T13:57:57Z")

</div>

You can either link accounts automatically if they have the same email address using a rule: [Auth0](https://auth0.com/rules/link-users-by-email)  
or do this manually via the API see: [https://auth0.com/docs/link-accounts](https://auth0.com/docs/link-accounts)  
(it appears you will need a paid subscription to link account via the api)

---

<div class="post-metadata">

**Author:** ![info24](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@info24](https://community.auth0.com/u/info24)\
**Post date:** [October 3, 2017, 8:32pm UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326/3 "2017-10-03T20:32:21Z")

</div>

Thanks for your help 🙂 We have been doing some testing but it seems when a user logins through with facebook account from Auth0 the email address is not returned by the API…?

---

<div class="post-metadata">

**Author:** ![Mark\_Redman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark_redman/32/6240_2.png) [@Mark\_Redman](https://community.auth0.com/u/Mark_Redman)\
**Post date:** [October 3, 2017, 8:45pm UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326/4 "2017-10-03T20:45:03Z")

</div>

After the user logs in (authenticated), using the available token, you should make a call via the management API to get the user which will return the UserId. You can create a rule to add additional claims that will also get sent back, you can include other user properties and metadata via the rule.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/we-are-implementing-custom-login-if-a-user-creates-an-account-and-then-logins-with-a-social-account-and-viceversa-how-do-we-recognize-its-the-same-user/8326/5 "2018-03-02T05:56:43Z")

</div>


