Hi! If you’re reading this, thanks!
I recently began a project that may take a while, and decided to add in a log in system. It’s pretty easy to use Repl.DB, but here’s the problem - after someone logins, and clicks a button, they get redirected. What if someone just types that link straight into the browser? I know there’s a way to stop that from happening, but how?
pretty simple, all you gotta do,(i will be using replauth for this example),
// check request headers to make suer they are logged in
if(req.get('X-Replit-User-Name') == '' || req.get('X-Replit-User-Name') == null) {
//if they are not logged in
res.redirect("login")
} else {
// they are logged in
res.send("whatever page u want to send");
}
Login Authentication (NodeJS Express)
Hi! If you’re reading this, thanks!
I recently began a project that may take a while, and decided to add in a log in system. It’s pretty easy to use Repl.DB, but here’s the problem - after someone logins, and clicks a button, they get redirected. What if someone just types that link straight into the browser? I know there’s a way to stop that from happening, but how?
Thanks!
pretty simple, all you gotta do,(i will be using replauth for this example),
this assumes you are using express
If you invite me to the repl i could probably make it more clear.