What is the best way to represent a login table with two types of Facebook and Conventional authentications?

Asked

Viewed 437 times

4

I have an Android app and have a conventional login Activity. Currently I want to add login with social networks. How best to store this type of distinct logins in tables. I create a single table or divide them.

  • Thank you did not know this type of login was called from Oauth. Thank you!

2 answers

4

when I needed to do this type of login I used a very simple table to record user information.

CREATE TABLE Usuario
(
    Id INTEGER NOT NULL IDENTITY,
    PessoaId INTEGER NULL
    LoginEmail VARCHAR(200) NOT NULL,
    Senha VARCHAR(30) NULL  
)

Note that there is information that is not mandatory (NULL), such as the password and the link with the Person table, where I record name, gender and other relevant information.

The biggest difficulty I had was to understand the flow of information when using this type of login (Oauth). In my researches I found some flows that helped me a lot and I would like to share:

Facebook

Fluxo do Facebook

Google | Microsoft | Linkedin

Fluxo do Google, MS e Linkedin

Below also follow links to get security privileges with networks:

Facebook Click here

Google Click here

Microsoft Click here

Linkedin Click here

I hope I’ve helped.

  • In this example when the user logs in the conventional way the person would be null and password filled. If login with personal facebook would be associated with the data table person who would be filled with information obtained from Facebook and the password field would be null?

  • If you have access to the information you can fill in the Person table. In my case I didn’t need it, so I would only fill the Person table if the user registration was performed directly on my system.

2

Boy, I use it in a single table. I don’t know if it’s the right way, but as it comes to Login, then one table is enough! If you analyze, there will be (theoretically) only one user, for several accounts, then there will be only one row in the table pro Facebook, Twitter, etc...

I hope I’ve helped! =)

  • It is that when the user is conventional the password field will be mandatory. Already when the user logs through social networks this information I do not have there I will record the null password field. This approach is a little strange because I was left with doubts.

  • @Rogerioesteves, try using the Constraint CHECK.

  • I have seen this very interesting article http://www.sitepoint.com/social-network-authentication-merging-accounts/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.