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!
I'm getting the error
Error: Failed to serialize user into sessionwhen testing login functionality. If I setsessiontofalsethen the error stops. The full stack trace of the error is:In index.js I have
site.login looks like
I've googled around extensively and it looks like most people get this error when
serializeUseris not defined. But I took a look andpassport-parsedefinitely defines both aserializeUseranddeserializeUsermethod.Any help would be great. Please let me know if I need to post more information.
Thanks!