https://supertokens.com/ logo
#support-questions
Title
# support-questions
c

cpalta

02/17/2022, 5:32 AM
Hi, i am using verify middleware in route and i have also my own middleware which i used to to set some data into session . in my own middleware i used next() function but after using verify middleware next function it show me a error "TypeError: Cannot read property 'secure' of undefined"
r

rp

02/17/2022, 5:33 AM
hey @User can you show us some code for how you have setup your middleware along with ours?
c

cpalta

02/17/2022, 5:37 AM
app .route("/api/session/test") .get(verifySession(),middleware.customMiddleware,); customMiddleware: async function(req, res, next) { let uid = req.session.getUserId(); var query = {}; query = {uid:uid}; if (uid) { User.findOne(query, function(err, user) { if (user) { next(); } else { res.send(401, { success: 'tokenexpire', message: 'Failed to authenticate token.' }); } }); } else { res.send(401, { message: 'No user'}); } }
getting these 2 error
TypeError: req.session.resetMaxAge is not a function at ServerResponse.res.end (/Users/empd/www/jini-forms/app/node_modules/express-session/index.js:178:19) at ServerResponse.res.send (/Users/empd/www/jini-forms/app/node_modules/express/lib/response.js:150:8) at ServerResponse.res.json (/Users/empd/www/jini-forms/app/node_modules/express/lib/response.js:191:15) at ServerResponse.res.send (/Users/empd/www/jini-forms/app/node_modules/express/lib/response.js:118:21) at /Users/empd/www/jini-forms/app/lib/controllers/system-notifications.js:149:25 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/model.js:4857:16 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/model.js:4880:21 at _hooks.execPost (/Users/empd/www/jini-forms/app/node_modules/mongoose/lib/query.js:4399:11) at /Users/empd/www/jini-forms/app/node_modules/kareem/index.js:136:16 at process._tickCallback (internal/process/next_tick.js:61:11) Emitted 'error' event at:
TypeError: Cannot read property 'secure' of undefined at ServerResponse.res.writeHead (/Users/empd/www/jini-forms/app/node_modules/express-session/index.js:141:18) at ServerResponse._implicitHeader (_http_server.js:200:8) at write_ (_http_outgoing.js:585:9) at ServerResponse.end (_http_outgoing.js:709:5) at /Users/empd/www/jini-forms/app/node_modules/express/lib/application.js:145:11 at next (/Users/empd/www/jini-forms/app/node_modules/express/lib/router/index.js:150:14) at next (/Users/empd/www/jini-forms/app/node_modules/express/lib/router/index.js:232:7) at next_layer (/Users/empd/www/jini-forms/app/node_modules/express/lib/router/route.js:77:14) at next_layer (/Users/empd/www/jini-forms/app/node_modules/express/lib/router/route.js:105:7) at /Users/empd/www/jini-forms/app/lib/middleware.js:193:28 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/model.js:4857:16 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/model.js:4857:16 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16 at /Users/empd/www/jini-forms/app/node_modules/mongoose/lib/model.js:4880:21 at _hooks.execPost (/Users/empd/www/jini-forms/app/node_modules/mongoose/lib/query.js:4399:11) at /Users/empd/www/jini-forms/app/node_modules/kareem/index.js:136:16 at process._tickCallba
r

rp

02/17/2022, 5:38 AM
Would appreciate if it is formatted correctly 😅
c

cpalta

02/17/2022, 5:40 AM
First error :- TypeError: req.session.resetMaxAge is not a function
second error:- TypeError: Cannot read property 'secure' of undefined
r

rp

02/17/2022, 5:42 AM
our session object doesn't have
resetMaxAge
as a function or a property. That seems to be coming from express-session lib. If you are using supertokens, you don't need to use express-session
Same goes for the
secure
property
Im not even sure how express-session is coming into the picture. The code above doesn't seem to use it. Maybe paste more of the code here?
c

cpalta

02/17/2022, 5:52 AM
we have use this and after remove express-session it is working
thanks for your help
r

rp

02/17/2022, 5:52 AM
great!
c

cpalta

02/17/2022, 5:52 AM
really appreciated
hi
i have another question
r

rp

02/17/2022, 9:52 AM
Sure
c

cpalta

02/17/2022, 9:52 AM
how much session time is set by default and if i need to change how i can i change the session time
r

rp

02/17/2022, 9:53 AM
Which recipe of ours are you using?
c

cpalta

02/17/2022, 9:53 AM
supertoken-web
and for core server i am setup with postgressql
and in backend we are using node server
r

rp

02/17/2022, 9:54 AM
i mean which recipe from here? https://supertokens.com/docs/community/recipes
c

cpalta

02/17/2022, 9:55 AM
right now we are using only email and password login
and for signup i did override the method
c

cpalta

02/17/2022, 10:03 AM
Ok thanks
3 Views