Skip to content

Cannot read property 'user' of undefined #137

@quantjin

Description

@quantjin

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions