Skip to content

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

@armyofda12mnkeys

Description

@armyofda12mnkeys

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions