V
V
Viktor2022-04-20 19:21:35
MySQL
Viktor, 2022-04-20 19:21:35

What is the database structure for authorization via email / password and social. networks?

The site now has the ability to register and log in via email / password (standard login and registration form). In general, all data from the social. I get networks, this is id, email, name, and the provider itself (google, facebook, etc.). Now the task arose of how to finalize the structure of the database so that you can register users through social networks, plus the ability to "link" all these social accounts into one in the profile.
For example, a user has already registered with one email and then logged out of the account. He has a social media account. networks with registration through the same email. Now, if the user decides to enter the site from this social. account, then he gets into his account that he created earlier (the email is the same) or is it a different account?
Secondly, if, for example, the third social account is registered to another email, is this another account? or in the profile, he decided to link this social account to the account, add a field in the database with, for example, an additional field email2?
And another question if, for example, the user does not have an email in the social account (registered via phone), how to register it? In general, advice is needed, any examples?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
TheAndrey7, 2022-04-20
@motto13

Now the task arose of how to refine the structure of the database so that you can register users through social networks, plus the ability to "link" all these social accounts into one in the profile.

Obviously it's better not to touch the table with local users who registered by email/password. I have the following table for linking third-party accounts: user_id, provider, account_id (user ID in the social network). Using such a table, it is not a problem to find a local user account and the user can link several accounts from different social networks.
And another question if, for example, the user does not have an email in the social account (registered via phone), how to register it? In general, advice is needed, any examples?
Not that it is not, but some APIs simply do not give it. Here, either require the user to specify an E-mail, or allow the creation of users with an empty E-mail.

A
Alexander Aksentiev, 2016-10-14
@fiercekilla

Well, wardump, so there is a difference.
The only trouble is with the logic...
First: if($row['name'] == $select)
Something that basically doesn't match gets into else, why do you have EXACTLY THE SAME CHECK there again, it will never return a match.

R
Rsa97, 2016-10-14
@Rsa97

The horror is terrible.
Why read all the rows from the database if you are only interested in the presence of one key in it?
Why ask for all fields if you only need one?
Why use mysql_ functions if they are no longer supported in new versions of PHP?
Why substitute data in a query without any protection against SQL injection?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question