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

sails.services.passport throwing issue #107

Open MindRave opened 9 years ago

MindRave commented 9 years ago

Hello everybody!

Here's an error I've just spent two hours on (error thrown when posting on the login route): "TypeError: Cannot read property 'initialize' of undefined at module.exports (/Users/JohnDoe/Developer/project_name/node_modules/sails-auth/dist/api/policies/passport.js:35:11)"

That line is the following: var passport = sails.services.passport;

Due to the issue, the server was throwing a 500 error every time I was trying to log in using a local strategy.

Replacing "var passport = sails.services.passport" with the usual "var passport = require('passport')" works just fine.

Now, I believe this means I won't be able to deploy my app on Heroku, seeing as the package.json components are built on heroku's servers, upon deployment, and I'm not able to just go in node_modules as I did here, and replace a line.

This also means, if that is the case, that I need to drop sails, as quickly as possible, to keep making progress on my project.

Any ideas on how to fix this outside of going inside "node_modules"? Do you need to see any of my other code (but seeing as replacing the line "just works", this shouldn't be an issue with my code, or should it?).

Using sails-auth version "2.1.1".

Thank you in advance!

anissen commented 9 years ago

I have got the same issue and have yet to get sails-auth to work. Using sails-auth 2.1.1 and sails 0.12.0-rc3. Any help would be appreciated.

MindRave commented 9 years ago

+1 (I know "plus ones" aren't great but I agree with @anissen - It'd be great to get some help. Thank you!)

gunish commented 9 years ago

+1

aliorouji commented 9 years ago

I'm having the same problem. +1

aratcliffe commented 9 years ago

Same here +1

MindRave commented 9 years ago

Hey everyone!

On my end, I managed to find a "solution" (so to speak, because it's more of a workaround than a real solution) by removing sails-auth entirely (npm uninstall sails-auth) and by using passport directly.

The solution resembles what you can find in this write up on "I Like Tomatoes": http://iliketomatoes.com/implement-passport-js-authentication-with-sails-js-0-10-2/

On my end, it works as it should using a local strategy (and it works on heroku).

Hope this issue gets fixed in the future.

mschraeder commented 9 years ago

I'm also getting this error on a fresh install.

How to reproduce:

sails new webapp cd webapp npm install sails-auth --save sails lift

I'm doing this is the latest versions.

elBarkey commented 8 years ago

+1 sails-auth@2.1.1 sails@0.12.0-rc3

talamaska commented 8 years ago

It is said in the sails docs how to call services http://sailsjs.org/documentation/concepts/services/creating-a-service

You should be able to call the Passport service directly.