Tag: passport.js

Using Passport.SocketIO cookie parser error

I am using the following: “dependencies”: { “express”: “^4.0.0”, “socket.io”: “0.9.16”, “mongoose”: “^3.8.8”, “passport”: “^0.2.0”, “passport-local”: “^1.0.0”, “express-session”: “^1.0.3”, “cookie-parser”: “^1.0.1”, “body-parser”: “^1.0.2”, “session-mongoose”: “git://github.com/danpe/session-mongoose.git#master”, “passport.socketio”: “^3.0.1” } Setting my socket.io authorization: io.set(“authorization”, passportSocketIo.authorize({ passport : passport, cookieParser: cookieParser(), key: settings.sessionKey, //the cookie where express (or connect) stores its session id. secret: settings.sessionSecret, //the session […]

NodeJS ExpressJS PassportJS – for Admin Pages Only

Im using NodeJS, ExpressJS, Mongoose, passportJS & connect-ensure-login. Authenticating users works perfectly. …. var passport = require(‘passport’) , LocalStrategy = require(‘passport-local’).Strategy , ensureLoggedIn = require(‘connect-ensure-login’).ensureLoggedIn; var app = express(); … app.use(passport.initialize()); app.use(passport.session()); … passport.use(new LocalStrategy({usernameField: ’email’, passwordField: ‘password’}, function(email, password, done) { User.findOne({ ’email’: email, ‘password’: password }, {‘_id’: 1, ’email’:1}, function(err, user) { if […]

ExpressJS/PassportJS: Authentication vs. Sessions

I am starting out with NodeJS (and web programming) and having trouble getting the authentication and sessions understood. I read many tutorials and just when I think I had it, I get confused. My problem is dealing with both authentication (Signup/Login) and persistent sessions. I am using PassportJS, and after many tutorials later, I think […]

Passport + Express V4 req.user undefined

I use the module passport to create authentication with session .. But since express v4 , there is no more tutorial .. and my authentication doesn’t work , in effect in my function that verify if the user is authenticated , the req.user is always undefined and req.isAuthenticated is false ! exports.ensureAuthenticated = function(req, res, […]

NodeJS express-validator with passport

I write a signup form table, and I use passport-local is work, but I want add express-validator to validate my form data. I add validation on the router, this is my router/index.js code: /* Handle Registration POST */ router.post(‘/signup’, function(req, res) { req.assert(’email’, ‘A valid email is required’).isEmail(); var errors = req.validationErrors(); if(errors){ //No errors […]

req.cookies in express is not being populated

I am setting a session cookie as part of PassportJS. I can see the connect.sid cookie being passed to the browser, and back to the application on subsequent HTTP requests. However, when I read req.cookies in one of my routes, it is empty. I have set up express.cookieParser(), express.session(), and passport.session() in configuration settings. Is […]

InternalOAuthError: Failed to obtain access token passport-instagram

I’m having a trouble with passport-instagram, I’m trying to implement passport-instagram to my application. Whenever I try to login using instagram login button I will get this error: InternalOAuthError: Failed to obtain access token {no matching code} Here’s the code instagram.js (passport instagram configuration file) var passport = require(‘passport’); var InstagramStrategy = require(‘passport-instagram’).Strategy; var User […]

Using CompoundJs with Passport

I’m trying to use Passport with Compound Js. I’ve configured the passport in an initialization file. as below var passport = require(‘passport’) , LocalStrategy = require(‘passport-local’).Strategy; passport.use(new LocalStrategy({usernameField: ’email’}, function(email, password, done) { User.findOne({ email: email }, function(err, user) { if (err) { return done(err); } if (!user) { return done(null, false, { message: ‘Incorrect […]

Does compoundjs-passport always expects user to be saved to the database after authentication?

I am developing a simple user crud module using compoundjs, compound-passport and passport-facebook. It used the default approach to generate a crud and it works fine if I want to save it to the database but I want to save it to a session here and save the user at a later stage the only […]

Blank page on node.js passport facebook redirect on mobile

I’m building a webservice based on node.js, I used passport authentication with the following setup: on calling authentication: clientID: “AAAA”, clientSecret: “BBBB”, callbackURL = “http://CCCC/facebook/loggedin”; app.get(‘/auth/facebook’, passport.authenticate(‘facebook’, {scope : [’email’, ‘publish_actions’, ‘rsvp_event’]}, {display: [‘touch’]})); Everything works perfectly fine via chrome on my desktop pc and I get redirected with all the parameters However, when trying […]

Node.js is the Best Javascript runtime in the world.