Skip to content
Snippets Groups Projects
Commit fd9ef216 authored by Elferink, A.S. (Amber)'s avatar Elferink, A.S. (Amber)
Browse files

voor het omschrijven naar redirect ipv send data

parent d435778a
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,21 @@ app.use(session({
activeDuration: 5 * 60 * 1000, //extend session for 5 mins with interaction
}));
/*If a get or post loads a page, for instance /myprofile, it wil look if the person is authorised to see it using this.
*/
var auth = function (req, res, next, user) {
if(req.session && req.session.user === user)
{
return next();
}
else
{
return res.sendStatus(401);
}
};
/* GET home page. */
router.post('/login', function (req, res) {
......@@ -36,6 +51,11 @@ router.get('/logout', function (req, res) {
res.send("logout success!");
});
router.get('/profile', auth, function (req, res) {
user = req.query;
res.send("You can only see this after you've logged in.")
});
module.exports = router;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment