Is there a equivalent to 'req.session.returnTo' clientside?
-
Hello!
In my custom route I use:
var requestedURL = req.originalUrl; // [...| req.session.returnTo = requestedURL; return res.redirect('/login');
to redirect the visitor to login page if he's not logged in.
I need this because the visitor calls:
nodebb.development.fail/discord/topic?param1=this¶m2=that
he should log in and after successful login he should be redirected to
nodebb.development.fail/discord/topic?param1=this¶m2=that
again.The GET-Params are absolutely necessarily.
It works like a charm if I call the page directly, but via
ajaxify
it does not work. So back to topic:Is there a equivalent to
req.session.returnTo
clientside?Thank you!
-
@dogs you replace
res.redirect
withhelpers.redirect
on the server side, then the redirect should work. -
What exactly isn't working? They aren't being redirected to the login page? They aren't being redirected after login?
You might need to use this:
NodeBB/src/controllers/helpers.js at 678e8f0fdef32cafbc63d16d0d22ef306a9c2cd3 路 NodeBB/NodeBB
Node.js based forum software built for the modern web - NodeBB/src/controllers/helpers.js at 678e8f0fdef32cafbc63d16d0d22ef306a9c2cd3 路 NodeBB/NodeBB
GitHub (github.com)
-
@pitaj I'm sorry. The page leaves blank after clicking the link. So it does not redirect to login. It turns white and endless loading spinner.
Excuse me but can you help me a little more. I don't know excatly how to deal with the given function...
I tried it but I cannot even trigger clientside javascript.
ajaxify.start
dont triggerajaxify.end
. Don't know how to trigger.But your sent link is on the serverside as well? Or isn't it?
-
@dogs you replace
res.redirect
withhelpers.redirect
on the server side, then the redirect should work.