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

Navigating to /auth/google causes an error #93

Open joniba opened 9 years ago

joniba commented 9 years ago

Any idea what could be the issue? (First time using sails and passport)

error: Sending 500 ("Server Error") response: TypeError: Cannot read property 'initialize' of undefined at module.exports (c:\code\node\bidding\demo\node_modules\sails-auth\dist\api\policies\passport.js:35:11) at routeTargetFnWrapper (C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\router\bind.js:179:5) at callbacks (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:164:37) at param (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:138:11) at pass (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:145:5) at nextRoute (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:100:7) at callbacks (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:167:11) at C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\router\bind.js:187:7 at module.exports (c:\code\node\bidding\demo\node_modules\sails-auth\dist\api\policies\basicAuth.js:13:12) at routeTargetFnWrapper (C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\router\bind.js:179:5) at callbacks (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:164:37) at param (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:138:11) at pass (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:145:5) at nextRoute (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:100:7) at callbacks (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:167:11) at C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\router\bind.js:187:7 at clearHeaders (C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\hooks\cors\index.js:209:3) at routeTargetFnWrapper (C:\Users\me\AppData\Roaming\npm\node_modules\sails\lib\router\bind.js:179:5) at callbacks (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:164:37) at param (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:138:11) at pass (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:145:5) at nextRoute (C:\Users\me\AppData\Roaming\npm\node_modules\sails\node_modules\express\lib\router\index.js:100:7) [TypeError: Cannot read property 'initialize' of undefined]

tjwebb commented 9 years ago

Did you install/configure the google passport plugin?

joniba commented 9 years ago

Yes of course. But I'm not clear on if/where/how I should be configuring the GoogleStrategy in my code...?

joniba commented 9 years ago

I created a sample to replicate this error here: https://github.com/joniba/test-sails-auth

This sample was created by running the following commands (windows 7):

sails generate new test-sails-passport cd new test-sails-passport npm install sails-auth --save npm install passport --save npm install passport-google --save sails generate api user

I also updated config/policies.js as you describe in the setup

Is something additional required in order to make this work?

palmtale commented 9 years ago

I found the same issue. And You can debug with breakpoint at that line where throw the exception, you will find

2015-10-16 8 04 25

And I checked , found the sails.service.passport did not be hooked by sails-auth. So...