Reputation: 157
I'm newbie to coding login systems and now I'm coding an account activation logic after registration.
I'm sending an email to the registered user with an url like this:
127.0.0.1:3000/activate/(token here)
And I'm handling it on server side when user access to that url on this way:
app.get('/activate', ( req, res) => {
res.sendFile( __dirname + '/public/activation.html')
})
But of course there's not a handler for every unique token so I need a way to access to enter on that app.get... /activate but kinda ignoring the second part where the token is so the file is served but keeping this token in a variable to operate with it later on it's inside logic.
How can achieve it? Am I totally wrong on my approach?
Thanks in advance.
Upvotes: 0
Views: 212
Reputation: 416
You can use dynamic link
app.get("/activation/:token",(req,res,next)=>{
const token = req.params.token;
//don't use token directly in sql database
});
Upvotes: 1