I am using the module to login to my website. Ok, after I log in the user, I present the website of my dashboard:
app.get ('/', function (req, res) {// check that the user's Credentials are saved or not a cookie // if (req.cookies.user == undefined || req.cookies.pass == undefined) {res.render (req.locale + '/ login', {title: ' Title - please login to your account '});} and {// attempted auto login // AM.autoLogin (req.cookies.user, req.cookies.pass, function (o) {if (o! = Null ) {Req.session.user = o; Res.redirect ('/ home');} else {res.render ('/ login', {title: 'hail} O - Please log in to your account '})}}}})}}};
After that, all other HTML websites dashboard Connected to Html, so there is no other app. Find the called methods.
If a user tries to navigate if the user is not logged in, then I (or any other HTML page that does not have a login page), I have to redirect it to the long page.
I had thought something like this before, t know that this is possible:
app.get ('I-don't-know-what-to -insert-here ', function (req, res) {if (req Session.user == null) {// If the user is not logged back then go to / res.redirect (' / ');} else on the login page {Res.redirect ('redirect-here-to-the-requested) -HTML-page')}});
Regards,
You want to write middleware, not the path Handler:
Apps. Uses (function (Rick, Race, Next) {if (req.session.user == null) {// If the user is not logged in, then redirect back Login page // res.redirect ('/');} else {next ();}});
No comments:
Post a Comment