Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'user' of undefined #137

Open
quantjin opened this issue Mar 17, 2016 · 2 comments
Open

Cannot read property 'user' of undefined #137

quantjin opened this issue Mar 17, 2016 · 2 comments

Comments

@quantjin
Copy link

Hello, I'm using sails 0.12.1, node 4.3.1, sails-auth 2.1.3, sails-permissions 2.2.0

When I tried to authorized with /auth/google or /auth/github, from the debug log, i can see the auth profile was fetched, but later there was error about Cannot read property 'user' of undefined

error:

warn: undefined 'TypeError: Cannot read property \'user\' of undefined\n    at 
\node_modules\\sails-auth\\dist\\api\\services\\passport.js:134:54\n    at proce
ssImmediate [as _immediateCallback] (timers.js:383:17)\nFrom previous event:\n  
at \node_modules\\sails-auth\\dist\\api\\services\\passport.js:131:34\n    at 
wrapper (\node_modules\\sails\\node_modules\\lodash\\index.js:3592:19)\n    at
applyInOriginalCtx (\node_modules\\sails\\node_modules\\waterline\\lib\\water
line\\utils\\normalize.js:417:80)\nat wrappedCallback (\node_modules\\sails\\nod
e_modules\\waterline\\lib\\waterline\\utils\\normalize.js:320:18)\n    at callba
ck.success (\node_modules\\sails\\node_modules\\waterline\\node_modules\\switchb
ack\\lib\\normalize.js:33:31)\n    at _switch (\node_modules\\sails\\node_module
s\\waterline\\node_modules\\switchback\\lib\\factory.js:58:28)\n    at returnRes
ults (\node_modules\\sails\\node_modules\\waterline\\lib\\waterline\\query\\find
ers\\basic.js:180:9)\n    at \node_modules\\sails\\node_modules\\waterline\\lib\
\waterline\\query\\finders\\basic.js:86:16\n    at \node_modules\\sails\\node_mo
dules\\waterline\\lib\\waterline\\query\\finders\\operations.js:83:7\n    at \no
de_modules\\sails\\node_modules\\waterline\\node_modules\\async\\lib\\async.js:5
2:16\n    at Object.async.forEachOf.async.eachOf(\node_modules\\sails\\node_modu
les\\waterline\\node_modules\\async\\lib\\async.js:236:30)\n    at Object.async.
forEach.async.each (\node_modules\\sails\\node_modules\\waterline\\node_modules\
\async\\lib\\async.js:209:22)\nFrom previous event:\n    at Deferred.then (\node
_modules\\sails\\node_modules\\waterline\\lib\\waterline\\query\\deferred.js:505
:27)\n    at Authenticator.passport.connect (\node_modules\\sails-auth\\dist\\ap
i\\services\\passport.js:108:6)\n    at Strategy.module.exports [as _verify] (\n
ode_modules\\sails-auth\\dist\\api\\services\\protocols\\oauth2.js:36:27)\n    
at \node_modules\\passport-github\\node_modules\\passport-oauth2\\lib\\strategy.
js:183:24\n    at\node_modules\\passport-github\\lib\\strategy.js:174:7\n    at 
passBackControl (\node_modules\\passport-github\\node_modules\\passport-oauth2\\
node_modules\\oauth\\lib\\oauth2.js:125:9)\n    at IncomingMessage.<anonymous> (
\node_modules\\passport-github\\node_modules\\passport-oauth2\\node_modules\\oau
th\\lib\\oauth2.js:143:7)\n    at emitNone (events.js:72:20)\n    at IncomingMes
sage.emit (events.js:166:7)\n    at endReadableNT (_stream_readable.js:905:12)\n
    at nextTickCallbackWith2Args (node.js:437:9)\n    at process._tickDomainCall
back (node.js:392:17)' [TypeError: Cannot read property 'user' of undefined]

i found a workaround with sails permission module on .sailsrc

.sailsrc

{
  "generators": {
    "modules": {
       "permissions-api": "node_modules/sails-permissions/generator"
    }
  }
}

with this sailsrc file, i can run sails generate permissions-api, but it only created config\permissions.js, are there supposed to be more created from the permissions-api?

Another question, what's the default callback behavior? is it redirecting to \ or something?

Thanks!

@jials
Copy link

jials commented Mar 27, 2016

#129 To solve the problem of property of undefined
#73 To redirect callback

@ahmadao
Copy link

ahmadao commented Jul 26, 2016

I can still see this problem because the dist inside package.json returns an older version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants