trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
266 stars 141 forks source link

Passport object undefined #127

Open fenichelar opened 8 years ago

fenichelar commented 8 years ago

When logging in I get an error. I am using Google Auth. The error is produced during the following block in passport.js:

  // Scenario: An existing user is trying to log in using an already
  //           connected passport.
  // Action:   Get the user associated with the passport.
  else {
    // If the tokens have changed since the last session, update them
    if (_.has(query, 'tokens') && query.tokens != passport.tokens) {
      passport.tokens = query.tokens;
    }

    // Save any updates to the Passport before moving on
    return passport.save()
      .then(function (passport) {

        // Fetch the user associated with the Passport
        return sails.models.user.findOne(passport.user.id);
      })
      .then(function (user) {
        next(null, user);
      })
      .catch(next);
  }

return sails.models.user.findOne(passport.user.id); errors because passport is undefined. Any ideas how to fix?

fruedaCode commented 8 years ago

I'm having the same issue. Any solution??

Thanks!

pawelhertman commented 8 years ago

@fenichelar @fruedaCode did you solve this problem?

fruedaCode commented 8 years ago

solve it! thanks!

2016-11-17 13:16 GMT+01:00 Paweł Hertman notifications@github.com:

@fenichelar https://github.com/fenichelar @fruedaCode https://github.com/fruedaCode did you solve this problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/langateam/sails-auth/issues/127#issuecomment-261232641, or mute the thread https://github.com/notifications/unsubscribe-auth/AVy63ywGWCcNtYtP97rFX-77eW9m7Zb-ks5q_EWigaJpZM4HakwJ .

pawelhertman commented 8 years ago

@fruedaCode could you write how did you do that? I know it has been fixed in 2.1.4 version, but the latest version of sails-auth in npm is 2.1.3. I tried to install v2.1.4 directly from repository, but I've got an error "cannot find module 'node_modules/sails-auth'" (although it exists)

fruedaCode commented 8 years ago

I directly changed that line on dist directory. But i think you could extend passport module and override the function.

jorgecasar commented 7 years ago

Solved by #128 and released on v2.1.4.

Please @tjwebb, could you publish on NPM the versions 2.1.4 and above?