microsoft / TypeScript-Node-Starter

A reference example for TypeScript and Node with a detailed README describing how to use the two together.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'picture' of undefined

hstandeffer opened this issue · comments

Followed the basic steps to cloning and setting up the project and am getting the following error, simply after creating an account seemingly successfully:

TypeError: C:\Users\---\---\---\views\partials\header.pug:27
    25|           li.nav-item.dropdown(class=(title === 'Account Management') ? 'active' : undefined)

    26|             a.nav-link.dropdown-toggle(href='#', data-toggle='dropdown')

  > 27|               if user.profile.picture

    28|                 img(src=user.profile.picture, alt=(user.profile.name || user.email || user.id))

    29|               else

    30|                 img(src=user.gravatar(60), alt=(user.profile.name || user.email || user.id))


Cannot read property 'picture' of undefined

I can reproduce the same issue.

I found this in passport.ts:

passport.deserializeUser((id, done) => {
    User.findById(id, (err: NativeError, user: UserDocument) => {
        done(err, user.id);
    });
});

Should be

passport.deserializeUser((id, done) => {
    User.findById(id, (err: NativeError, user: UserDocument) => {
        done(err, user);
    });
});

instead!? (returning user instead of user.id)