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

TypeError: Cannot read property 'passport' of undefined #7

Closed
acertain opened this issue Nov 29, 2012 · 8 comments
Closed

TypeError: Cannot read property 'passport' of undefined #7

acertain opened this issue Nov 29, 2012 · 8 comments
Assignees
Labels

Comments

@acertain
Copy link

TypeError: Cannot read property 'passport' of undefined
    at Object.module.exports.passport.use.done.message [as handle] (/Users/cartercharbonneau/ddderby/node_modules/derby-auth/index.js:58:36)
    at next (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.module.exports [as handle] (/Users/cartercharbonneau/ddderby/node_modules/derby-auth/node_modules/connect-flash/lib/flash.js:20:5)
    at next (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.expressInit [as handle] (/Users/cartercharbonneau/ddderby/node_modules/express/lib/middleware.js:31:5)
    at next (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.query [as handle] (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)
    at next (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Function.app.handle (/Users/cartercharbonneau/ddderby/node_modules/express/node_modules/connect/lib/proto.js:198:3)
    at Object.app.use.fn [as handle] (/Users/cartercharbonneau/ddderby/node_modules/express/lib/application.js:117:11)
@ghost ghost assigned lefnire Nov 29, 2012
@lefnire
Copy link
Owner

lefnire commented Nov 29, 2012

hm, can't reproduce - try again, there were some changes recently. make sure your server.js file matches the example app, which was also recently changed. if still buggy, re-open

@lefnire lefnire closed this as completed Nov 29, 2012
@acertain
Copy link
Author

I'm not using that, but a minimal one from the README:

express = require 'express'
derby = require 'derby'
racer = require 'racer'

strategies =
  google:
    strategy: require('passport-google').Strategy
    conf:
      clientId: process.env.GOOGLE_KEY
      clientSecret: process.env.GOOGLE_SECRET
      returnURL: '/'
options =
  domain: 'http://localhost:3000'
  allowPurl: true

derby.use(derby.logPlugin)
racer.use(racer.logPlugin)

expressApp = express()
server = require('http').createServer expressApp

# The server-side store syncs data over Socket.IO
store = derby.createStore listen: server

expressApp
  .use(express.static __dirname + '/public')
  .use(store.modelMiddleware())
  .use(require('derby-auth')(store, strategies, options))
  .use(require('./hello').router())

server.listen 3000

@lefnire
Copy link
Owner

lefnire commented Nov 29, 2012

git the latest push a shot, a3da0e6

@lefnire
Copy link
Owner

lefnire commented Nov 29, 2012

You know what, I hit this issue too just recently - and there was no reason it should have been happening, so I just ran rm -rf node_modules/* && npm install and it seemed ok... strange.

@acertain
Copy link
Author

No cigar, using git.

@acertain
Copy link
Author

acertain commented Dec 8, 2012

I made some changes to my server.js and it works:

express = require 'express'
derby = require 'derby'
racer = require 'racer'

strategies =
  google:
    strategy: require('passport-google').Strategy
    conf:
      clientId: process.env.GOOGLE_KEY
      clientSecret: process.env.GOOGLE_SECRET
      returnURL: '/'
options =
  domain: 'http://localhost:3000'
  allowPurl: true

derby.use(derby.logPlugin)
racer.use(racer.logPlugin)

expressApp = express()
server = require('http').createServer expressApp

# The server-side store syncs data over Socket.IO
store = derby.createStore listen: server

expressApp
  .use(express.favicon())
  .use(require('gzippo').staticGzip(__dirname + '/public'))
  .use(express.compress())
  .use(express.cookieParser()) 
  .use(store.sessionMiddleware
    secret: process.env.SESSION_SECRET || 'default_secret'
    cookie: {maxAge: 1000 * 60 * 60 * 24 * 365}
  )
  .use(store.modelMiddleware())
  .use(require('derby-auth')(store, strategies, options))
  .use(require('./hello').router())

server.listen 3000

@ile
Copy link

ile commented Jan 9, 2013

Had the same issue, uncommented these uses and it started working (at least got through this issue)

  # Uncomment and supply secret to add Derby session handling
  # Derby session middleware creates req.session and socket.io sessions
  .use(express.cookieParser())
  .use(store.sessionMiddleware
    secret: process.env.SESSION_SECRET || 'YOUR SECRET HERE'
    cookie: {maxAge: ONE_YEAR}
  )

Does this need to be added to the documentation?

Thanks for the derby-auth btw.

@lefnire
Copy link
Owner

lefnire commented Jan 9, 2013

oh those are definitely required, i'll add them to the documentation

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

No branches or pull requests

3 participants