Tuesday 24 March 2020

Can you add an overlay menu using Express?

I'm currently taking Colt Steele's web dev bootcamp. I've been coding along with it, but I didn't want a carbon copy of what he's done, so I learned a lot more about CSS and DOM manipulation on the side to keep things interesting. I know how to do an overlay menu normally. I have one started on the landing page already. But now I'm trying to implement it into authentication. I'm just learning authentication now, and am using Passport as an extension. What I'm trying to do is make it so that a user can only make a post if they log in. I know how to set it up where it just redirects you to the login page and once you log in it works fine. but what i want is for a menu to come up when you click the button that says you need to be logged in to comment and it gives you the option to login, sign up, and exit. the thing is, i don't know how to do that where it only does that when you're not logged in. once logged in I want to be able to click the submit button and be redirected to the comment posting page, but currently the menu just pops up every time, and when i try other changes, then the menu doesn't pop up and it just goes straight to the post page. not sure if this is totally clear so i have the snippet of code im trying to fix.function isLoggedIn(req, res, next) {if (req.isAuthenticated()) {return next();  }res.redirect('/login');}​so instead of redirecting to the login page, i want it to bring up the menu where i can click login and be taken there. i know it's not necessary, but i'm trying to make things more creative and by doing this im ultimately learning more than just coding along and not making changes. thanks in advance. sorry for not being articulate enough, i'm new to this so trying to explain it isn't the easiest, especially since i don't always know what i'm doing...

Submitted March 25, 2020 at 02:30AM by zolavt

No comments:

Post a Comment