I have a login with a form that has the attribute action="api/login", after loging in, it renders a page and shows a pathname of http://localhost:3000/api/login. I want it to say http://localhost:3000/dashboard. I tried redirecting /dashboard then rendering, but I just got a blank page. Below is my code. I am using NodeJS, I have a route folder that calls to the Auth Controller.
//html form
<form method='post' action="api/login">
//route
router
.route('/login')
.post(ctrlAuth.login);
module.exports.login = function(req, res) {
////DOES AUTH CODE STUFF here//////
res
.status(200)
.render('holder', {
device: req.session.device,
id: req.session.id,
first_name: req.session.first_name,
last_name: req.session.last_name,
role: req.session.role,
users: user_data
});
})
})
} else {
console.log('password incorrect')
res.redirect('/home')
}
});
})
};
via Edwin Rodriguez
No comments:
Post a Comment