Skip to content

Error: Failed to serialize user into session #4

@jgaull

Description

@jgaull

I'm getting the error Error: Failed to serialize user into session when testing login functionality. If I set session to false then the error stops. The full stack trace of the error is:

Error: Failed to serialize user into session
    at pass (/Users/Jon/Code/Ryde/Server/node_modules/passport/lib/authenticator.js:271:19)
    at Authenticator.serializeUser (/Users/Jon/Code/Ryde/Server/node_modules/passport/lib/authenticator.js:289:5)
    at IncomingMessage.req.login.req.logIn (/Users/Jon/Code/Ryde/Server/node_modules/passport/lib/http/request.js:50:29)
    at Strategy.strategy.success (/Users/Jon/Code/Ryde/Server/node_modules/passport/lib/middleware/authenticate.js:235:13)
    at ParsePromise.success (/Users/Jon/Code/Ryde/Server/node_modules/passport-parse/lib/strategy.js:81:25)
    at ParsePromise.<anonymous> (/Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:317:27)
    at ParsePromise.wrappedResolvedCallback (/Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:153:43)
    at ParsePromise.value (/Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:89:36)
    at ParsePromise.<anonymous> (/Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:163:29)
    at ParsePromise.wrappedResolvedCallback (/Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:153:43)
    at /Users/Jon/Code/Ryde/Server/node_modules/parse/lib/node/ParsePromise.js:219:35
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

In index.js I have

app.use(cookieParser())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(session({
  secret: 'a secret',
  resave: true,
  saveUninitialized: true,
  store: new ParseStore({
    client: Parse
  })
}));

var parseStrategy = new ParseStrategy({
  parseClient:Parse,
  appId: appId
})

passport.use(parseStrategy)

app.use(passport.initialize())
app.use(passport.session())

app.get('/login', site.loginForm)
app.post('/login', site.login)
app.get('/logout', site.logout)

app.get('/dialog/authorize', oauth2.authorization)
app.post('/dialog/authorize/decision', oauth2.decision)
app.post('/oauth/token', oauth2.token)

site.login looks like

exports.login = passport.authenticate('parse', {
	session: true,
	successRedirect: '/dialog/authorize/decision',
	failureRedirect: '/login'
})

I've googled around extensively and it looks like most people get this error when serializeUser is not defined. But I took a look and passport-parse definitely defines both a serializeUser and deserializeUser method.

Any help would be great. Please let me know if I need to post more information.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions