{"id":2905,"date":"2014-03-10T12:27:04","date_gmt":"2014-03-10T12:27:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/node-jspassportrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-03-10T12:27:04","modified_gmt":"2014-03-10T12:27:04","slug":"node-jspassportrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/node-jspassportrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"node.js,passportRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/TJwu1.jpg?s=32&amp;g=1\" \/><br \/>\n???????? ????????<br \/>\nnode.js npm vagrant provisioning<br \/>\nDuring Vagrant Shell provision I try to install NodeJS and NPM on Debian Wheezy. Script is (from guide https:\/\/github.com\/joyent\/node\/wiki\/backports.debian.org):sudo echo &#8220;deb http:\/\/ftp.us.debian.org\/debian wheezy-backports main&#8221; &gt;&gt; \/etc\/apt\/sources.list sudo apt-get update sudo apt-get install -y nodejs-legacy curl https:\/\/npmjs.org\/install.sh | sudo shNode sets up as a charm, but NPM installation fails:Stderr from the command:stdin: is not a tty dpkg-preconfigure: unable to re-open stdi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/78a0a4bb106d07b6c6f33a51988155e3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeter Mortensen<br \/>\nmysql node.js npm visual-studio-2013<br \/>\nWhen I&#8217;m trying to install the Node.JS MySQL module trough Visual Studio 2013 npm Package Management, the installation fails due to the following errors:npm ERR! Failed to parse json npm ERR! Unexpected token How do I solve this or is there another way to do this?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/87a584de59493d25e2049b75bc20a033?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlowerkey<br \/>\njavascript node.js try-catch try-catch-finally<br \/>\nI read about try catch(e if e instanceof &#8230;) blocks on MDN, however, upon trying it in Node.js, I get a SyntaxError: Unexpected token if.If this doesn&#8217;t work, is there another way to catch specific exceptions, instead of everything that might occur?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9c4efe35d1f6cbffe9ce50e600175900?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngpasse<br \/>\nnode.js meteor<br \/>\nI managed to deploy meteor on my infrastructure (Webfactions). The application seems to work fine but I get the following error when my application starts :WebSocket connection to &#8216;ws:\/\/myapp.mydomain.com\/sockjs\/656\/ll_djq7e\/websocket&#8217; failed: Unexpected response code: 400 I am not sure what to do to solve the problem.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d8238ae773f9d75e510abe305209189f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntrusktr<br \/>\nnode.js coffeescript<br \/>\nI npm installed the node-term-ui package, but I keep getting &#8220;Unexpected string&#8221; errors, then I noticed the syntax in the files looks different, and realized it&#8217;s CoffeeScript which I&#8217;ve never used before.How do I make it work?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9c6f5c78dece456732470626d552b16c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndres Riofrio<br \/>\njavascript node.js throw<br \/>\nHere is what I want to do:var setting = process.env.SETTING || throw new Error(&#8220;please set the SETTING environmental variable&#8221;);^^^^^But the interpreter complains about &#8220;Syntax Error: Unexpected token throw&#8221;.Is there any way to throw an exception in the same line that we compare whether a value is falsey or not?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aa5b911b73f8cbe0bf72bab67f061ce1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCamelCamelCamel<br \/>\nruby ruby-on-rails-3 node.js redis resque<br \/>\nI want to queue Resque jobs from NodeJS. Monitoring Redis commands I see:1346127083.495055 &#8220;sadd&#8221; &#8220;resque:w:tasks:queues&#8221; &#8220;facebook&#8221; 1346127083.495471 &#8220;rpush&#8221; &#8220;resque:w:tasks:queue:facebook&#8221; &#8220;{\\&#8221;class\\&#8221;:\\&#8221;Hello::FacebookFriends\\&#8221;,\\&#8221;args\\&#8221;:[\\&#8221;2342324\\&#8221;]}&#8221;Issuing those commands directly from Node seems to work. Are there any hidden bugs or things I&#8217;m not aware of here?Update: My jobs are written in Ruby. While I love NodeJS and I&#8217;m way better in Javascript, I need tons of libraries that are still<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/09cfe0ba3a1eed4a9a1886a310cd7b0c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1020015<br \/>\nnode.js mongodb ubuntu meteor<br \/>\nI am using a fresh linux install. I am trying to install meteor. Using Ubuntu 12.04, Centos and Ubuntu 13.04. I installed NodeJs, Meteor and Meteorite. But I get this error:Unexpected mongo exit code 100. Restarting.Unexpected mongo exit code 100. Restarting.Unexpected mongo exit code 100. Restarting.Can&#8217;t start mongodMongoDB had an unspecified uncaught exception. This can be caused by MongoDB being unable to write to a local database. Check that you have permissions to write to .meteor\/local. M<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d0257ee6d5213d2d1064cf7f8fc083e9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\npb2q<br \/>\nnode.js foreach associative-array jade<br \/>\nOk, I am getting an associative array from node server and trying to render it in Jade. I obviously need a foreach loop, but nothing seems to work! I tried these both codes:- foreach row in rows {li= row &#8211; }and- rows.forEach(function(item)) {li= item &#8211; })the array I am passing is called &#8220;rows&#8221;. Any idea why this is not working? I am getting this error:500 SyntaxError: Unexpected identifierand, with the second code:500 SyntaxError: Unexpected token )<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fd534845b7649684294e0b4154741149?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSean Mickey<br \/>\njson node.js express<br \/>\nI installed node.js and express.js and I&#8217;m trying to use: var str = { test: &#8216;info&#8217;}; obj = JSON.parse(str);but it causes an error: SyntaxError: Unexpected token 0 at Object.parse (native)How can I fix this? Thanks.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/9qCf8.jpg?s=32&amp;g=1\" \/><br \/>\nmfreitas<br \/>\nnode.js authentication angularjs express passport<br \/>\nI&#8217;m starting to experiment with expressJS + angularJS and i&#8217;ve run into a stressful situation.My goal is to have one login page and one dashboard page, and using passport + mongodb i&#8217;ll authenticate a user in and, if credentials are correct, redirect him to the dashboard page.I&#8217;ve started with the angular-express-seed and modified it so i ended up with the previously mentioned views:$routeProvider.when(&#8216;\/login&#8217;, {templateUrl: &#8216;partials\/login&#8217;,controller: &#8216;LoginCtrl&#8217;}).when(&#8216;\/dashboard&#8217;, {templat<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c72291fc10f48e277cadb77bf254f21c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nasgoth<br \/>\napi node.js oauth express passport<br \/>\nI&#8217;ve got I think a specific problem, unless I&#8217;m not doing things in the right way.I&#8217;ve got an application with 2 sides, a client (html site), and an API (built with express + mongodb). The API will need to be securely accessed. They both are on different domains, for now let&#8217;s say my site is on domain.com and my API is on api.com:3000.I&#8217;ve added passport to get an access token from Github as I&#8217;m creating my users with their data, so I can have a &#8220;Sign in with Github&#8221; basically.My current process<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2e31e36dd97e5ffb962d97811cd56800?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCarlos<br \/>\nnode.js express passport<br \/>\nI have a server in node.js using express and passport with the passport-local strategy.I have the users in the database and through passport I&#8217;m able to authenticate them, unfortunately when a second request comes from the same client the req.isAuthenticated() method returns false. There is also no user in the request (req.user = undefined). I&#8217;ve also checked and when doing the authentication although I get back a user from passport.authenticate(&#8216;local&#8217;&#8230; I do not get req.user populated then.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/77e4f26b2b775804eba6858213d9bcd9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMantissa<br \/>\nnode.js passport passportjs<br \/>\nI&#8217;m new to node and am trying to get a simple local login up and running using passport.js. It looks to me that the strategy that I have set up is not being run when the authenticate function is called. module.exports = function(app) { var mongo = require(&#8216;.\/mongoose-db.js&#8217;); var brands = require(&#8216;.\/app\/brands.js&#8217;);\/\/ brand admin page \/\/var passport = require(&#8216;passport&#8217;); var LocalStrategy = require(&#8216;passport-local&#8217;).Strategy;passport.use(new LocalStrategy( {\/\/this is a strategy but why is it no<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/39768687d4abba12692e4105d1f2836b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmilestyle<br \/>\nnode.js oauth-2.0 passport bit.ly<br \/>\nI&#8217;m trying to authenticate to bitly so I can use the link-shortener and track the users&#8217; metrics. My implementation is like this:passport.use(new BitlyStrategy({clientID: &#8220;my client id here&#8221;,clientSecret: &#8220;my secret here&#8221;,callbackURL: &#8220;http:\/\/website.com\/auth\/bitly\/callback&#8221; }, function (token, tokenSecret, profile, done) { \/\/ Code to put it in the server here. } ));And the routes look like this:app.get(&#8216;\/auth\/bitly&#8217;,passport.authenticate(&#8216;bitly&#8217;));app.get(&#8216;\/auth\/bitly\/callback&#8217;, passport.authe<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3ceb60b6cf5ce1fbd7e22e1066183f92?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmaddy<br \/>\nnode.js express varnish passport<br \/>\nI&#8217;m a php dev, trying to understand node.js.. i can&#8217;t find the answer.. I&#8217;m making a little chat, using passport for authentication. I&#8217;ve made a facebook Strategy which works very well. I&#8217;ve made a google Strategy and i can&#8217;t figure out what&#8217;s happenning : I click on the google login, i&#8217;m redirected by google to the chat, and then i have to wait untill varnish gives me a &#8220;Error 503 Service Unavailable&#8221;.. But Node has not crashed !So varnish in front, node.js behind.. and here is my code..passp<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9ef46be663413b534c324ebbee88001b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAntelopeSalad<br \/>\nnode.js express mongoose passport<br \/>\nI&#8217;ve successfully implemented passport-local into my express\/mongoose web app but I&#8217;m having trouble figuring out how to render a failed login message properly.Here&#8217;s my login route:app.get(&#8216;\/login&#8217;, function(req, res) {res.render(&#8216;user\/login&#8217;, {}); });With a route like that how am I supposed to report an invalid login? If the login is successful it will write the id\/username to the req.user object but that doesn&#8217;t help me in the GET \/login route because if it&#8217;s successful you will get redirecte<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/J7Ixh.jpg?s=32&amp;g=1\" \/><br \/>\nKundu<br \/>\nnode.js express cors passport<br \/>\nI am using passport JS, express and mongoose to make an API. When I test it in same domain it maintain session and works fine. But in cross domain it fails. Any clue how can i maintain the session in cross domain using the same configuration. Following is the codeallowCrossDomain = function(req, res, next) {res.header(&#8220;Access-Control-Allow-Origin&#8221;, &#8220;*&#8221;);res.header(&#8220;Access-Control-Allow-Methods&#8221;, &#8220;GET, POST, PUT, DELETE, OPTIONS&#8221;);res.header(&#8220;Access-Control-Allow-Headers&#8221;, req.headers[&#8220;access-con<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8dc15177b5d34a75d9078d556f959cf1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJavier Manzano<br \/>\njavascript node.js oauth passport compoundjs<br \/>\nI&#8217;m facing this problem with compound passport. I&#8217;ve already followed the steps from the guide but I cannot get this working when I try to access \/auth\/github.Any tips?GET \/auth\/github controller: auth action: github Params: {&#8220;controller&#8221;:&#8221;auth&#8221;,&#8221;action&#8221;:&#8221;github&#8221;} &gt;&gt;&gt; perform github Error: Undefined action auth#github(\/auth\/github) at Object.FlowControl.call.context.innerNext (\/Users\/javiermanzanomorilla\/Development\/workspace\/authapp\/node_modules\/compound\/node_modules\/kontroller\/lib\/fl<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/87e2be1de6e440282c3fd8d81243d926?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRaf<br \/>\nfacebook node.js authentication passport passportjs<br \/>\nI must be overlooking something here. I&#8217;m using the Facebook strategy of passportjs to authenticate users. This is done with 2 requests\/[route handlers]:\/\/one to initiate the the auth: init: function (req, res, next) {passport.authenticate(&#8216;facebook&#8217;, {callbackURL: URL + &#8216;\/facebook\/callback&#8217;,state: req.body \/\/attempting to put some state})(req, res, next) }\/\/one callback callback: function (req, res, next) {passport.authenticate(&#8216;facebook&#8217;, {callbackURL: URL + &#8216;\/facebook\/callback&#8217;},function (err<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>???????? ???????? node.js npm vagrant provisioning During Vagrant Shell provision I try to install NodeJS and NPM on Debian Wheezy. Script is (from guide https:\/\/github.com\/joyent\/node\/wiki\/backports.debian.org):sudo echo &#8220;deb http:\/\/ftp.us.debian.org\/debian wheezy-backports main&#8221; &gt;&gt; \/etc\/apt\/sources.list sudo apt-get update sudo apt-get install -y nodejs-legacy curl https:\/\/npmjs.org\/install.sh | sudo shNode sets up as a charm, but NPM installation fails:Stderr from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2905","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2905"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2905\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}