How to redirect via a simple method?
-
I tried to do an account synchronization plugin, but the middle of the need to force the routing of the jump.(I want to use
filter:router.page
,but i don't know how to use it.)
I triedfilter:middleware.render
, like below: (But it is not a friendly way.I want to handle redirect via a simple method.Cloud you help me ? Thanks you.)if (data.req.session.hasOwnProperty('connect') && !(Array.isArray(data.templateData.url.match(/register/))) && (!data.req.hasOwnProperty('user') || !data.req.user.hasOwnProperty('uid') || data.req.user.uid === 0)) { if (data.req.headers['x-requested-with'] && data.req.headers['x-requested-with'].toLowerCase() === 'xmlhttprequest') { // is ajax callback(new Error('Emmm. Use F5 to redirect truly page')) } else { // is common request data.res.redirect('/register') callback(null, data) } } else if (data.req.session.hasOwnProperty('cuser') && !(Array.isArray(data.templateData.url.match(/connect\/login/)))) { if (data.req.headers['x-requested-with'] && data.req.headers['x-requested-with'].toLowerCase() === 'xmlhttprequest') { // is ajax callback(new Error('Emmm. Use F5 to redirect truly page')) } else { // common request data.res.redirect('/connect/login') callback(null, data) } } else { .........
Copyright © 2024 NodeBB | Contributors