Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about FB documentation... needs an update? #292

Open
armyofda12mnkeys opened this issue Aug 20, 2023 · 0 comments
Open

Question about FB documentation... needs an update? #292

armyofda12mnkeys opened this issue Aug 20, 2023 · 0 comments

Comments

@armyofda12mnkeys
Copy link

Had a question about the FB passport README (which i guess also shows up on the docs here: https://www.passportjs.org/concepts/authentication/facebook/ )...

The docs/README insert a user if the user never signed in yet:
db.run('INSERT INTO users (name) VALUES (?)', [profile.displayName]

Only thing inserted there is a displayName from FB (and implicitly a autoincremented ID). That autoincremented ID then gets inserted into federated_credentials along with their unique FB ID (profile.id).

db.run('INSERT INTO federated_credentials (user_id, provider, subject) VALUES (?, ?, ?)', [
            id,
            'https://www.facebook.com',
            profile.id
          ]

Later if the user is signing in and they already signed in be4 (and hence exist in the above 2 tables), it will try to get their info from the DB... the cred.user_id i assume is FB passing along their unique FB ID from the front-end to this back-end url ...
db.get('SELECT * FROM users WHERE id = ?', [ cred.user_id ], function(err, user) {
But that FB ID isn't inserted initially in the user table, its in the other federated_credentials table?

Should the docs be updated so the query to find the user searches the federated_credentials table (and then joins back to user to get other fields that may be in there like displayName/email ?

Thanks,
Arian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant