Advanced Node and Express: Error when populating user fields

Hey everyone, I want to address an issue in Advanced Node and Express - Implementation of Social Authentication III, copying the code provided by FCC gives me this error when I try to login using Github

TypeError: Cannot read property '0' of undefined
    at Strategy.passport.use.GithubStrategy [as _verify] (/app/server.js:54:38)
    at /rbd/pnpm-volume/e07de6dc-b78e-4eb7-b086-e6e334e59858/node_modules/
    at /rbd/pnpm-volume/e07de6dc-b78e-4eb7-b086-e6e334e59858/node_modules/
    at passBackControl (/rbd/pnpm-volume/e07de6dc-b78e-4eb7-b086-e6e334e59858/node_modules/
    at IncomingMessage.<anonymous> (/rbd/pnpm-volume/e07de6dc-b78e-4eb7-b086-e6e334e59858/node_modules/
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/proc

The code:

        name: profile.displayName || 'John Doe',
        photo:[0].value || '',
        email: profile.emails[0].value || 'No public email',
        created_on: new Date(),
        provider: profile.provider || ''
        last_login: new Date()
        login_count: 1
    {upsert:true, new: true},
    (err, doc) => {
        return cb(null, doc.value);

I found that my code errors out cause my Github email is not public so it’s not provided in the profile object
I had to change the email field to email: profile.emails ? profile.emails[0].value : 'No public email',
I think for photo as well, I’m not sure if Github provide a default photo