I try to make a page accessible only after some verification. Then I have a form for the verification whose route is "/", once the verification is completed successfully, it is redirected to the "/ send" page to send the money. If I type in URL "/", the form is displayed and all is passed well. But if I type "/ send" the page where I'm going to send the money opens without that it asks me for verification. How I can forbid access to a page every time the user accesses this page only when he fills out the verification form with success.
//get send money form
router.get('/send',function (req, res, next)
{
res.render('transfer.ejs');
});
// get the verification page
router.get('/',function (req, res, next)
{
res.render('verification.ejs');
});
//unlock account function
function unlockAccount(val,myaddress,callback)
{
//here I make somme verification
}
//transfer token
router.post('/send', function(req, res, next) {
//here the code of the transfer page
});
//checking account
router.post('/',function (req, res, next)
{
unlockAccount(req.body.password,req.body.myaddress,
function(err,response) {
var bool=Boolean(response);
if (bool)
{
res.redirect("/send");
}
else
{
res.redirect("/");
}
});
});
via takampika
No comments:
Post a Comment