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

Not Return Status Code 401 for API access without token #11

Open
twhtanghk opened this issue Sep 18, 2013 · 2 comments
Open

Not Return Status Code 401 for API access without token #11

twhtanghk opened this issue Sep 18, 2013 · 2 comments

Comments

@twhtanghk
Copy link

Try to access api without defining the token. The server reports property 'statusCode' assigned with 'undefined' value at 150 of passport authenticate.js. Any suggestion to fix the statement res.statusCode = rstatus || 401; if rstatus is undefined.

TypeError: Cannot set property 'statusCode' of undefined
at allFailed (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/authenticate.js:150:22)
at attempt (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/authenticate.js:231:28)
at Context.module.exports.delegate.fail (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/authenticate.js:226:9)
at Context.actions.fail (/home/whtang/workspace/uc/node_modules/passport/lib/passport/context/http/actions.js:35:22)
at Strategy.authenticate (/home/whtang/workspace/uc/node_modules/passport-http-bearer/lib/strategy.js:113:29)
at attempt (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
at Passport.authenticate (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
at zappa.app.route (/home/whtang/workspace/uc/node_modules/zappa/lib/zappa.js:490:34)
at callbacks (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/lib/router/index.js:272:11)
at param (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/lib/router/index.js:246:11)
at pass (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/lib/router/index.js:280:5)
at Object.middleware as handle
at next (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Passport.initialize (/home/whtang/workspace/uc/node_modules/passport/lib/passport/middleware/initialize.js:69:5)
at next (/home/whtang/workspace/uc/node_modules/zappa/node_modules/express/node_modules/connect/lib/http.js:204:15)
at resume (/home/whtang/workspace/uc/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7)
at SendStream.error (/home/whtang/workspace/uc/node_modules/express/node_modules/connect/lib/middleware/static.js:73:37)
at SendStream.EventEmitter.emit (events.js:95:17)
at SendStream.error (/home/whtang/workspace/uc/node_modules/express/node_modules/send/lib/send.js:147:51)
at SendStream.onStatError (/home/whtang/workspace/uc/node_modules/express/node_modules/send/lib/send.js:248:48)
at SendStream.pipe (/home/whtang/workspace/uc/node_modules/express/node_modules/send/lib/send.js:320:26)
at Object.oncomplete (fs.js:107:15)

Thanks,
Tommy Tang

@twhtanghk
Copy link
Author

Problem fixed by fall back from Zappajs to Coffee Script. It seems that Zappajs not properly passed response to middleware so that the undefined "res" is referenced in statement res.statusCode = rstatus || 401.

Thanks,
Tommy Tang

@peteruithoven
Copy link

Maybe close this issue if it's fixed?

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

2 participants