From 0c7bb17b8c955254c2db61a5fe9c8240ea1357e2 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Fri, 16 Apr 2021 21:37:26 -0500 Subject: finish hw6 --- csci4131/hw6/strap012_hw6/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'csci4131/hw6/strap012_hw6/index.js') diff --git a/csci4131/hw6/strap012_hw6/index.js b/csci4131/hw6/strap012_hw6/index.js index 474b165..851b096 100644 --- a/csci4131/hw6/strap012_hw6/index.js +++ b/csci4131/hw6/strap012_hw6/index.js @@ -49,15 +49,19 @@ app.get('/', function (req, res) { // GET method route for the contacts page. // It serves contact.html present in public folder app.get('/contacts', function(req, res) { - if(!req.session.value) { + if(!req.session.user) { res.redirect('/login'); } else { res.sendFile(path.join(__dirname, 'public/contacts.html')); } }); +app.get('/stocks', function(req, res) { + res.redirect('/stock'); +}) + app.get('/stock', function (req, res) { - if (!req.session.value) { + if (!req.session.user) { res.redirect('/login'); } else { res.sendFile(path.join(__dirname, 'public/stock.html')); @@ -65,7 +69,7 @@ app.get('/stock', function (req, res) { }); app.get('/addContact', function (req, res) { - if (!req.session.value) { + if (!req.session.user) { res.redirect('/login'); } else { res.sendFile(path.join(__dirname, 'public/addContact.html')); @@ -73,13 +77,17 @@ app.get('/addContact', function (req, res) { }); app.get('/login', function (req, res) { - if (req.session.value) { + if (req.session.user) { res.redirect('/contacts'); } else { res.sendFile(path.join(__dirname, 'login.html')); } }); +app.get('/logout', function(req, res) { + res.redirect('/api/logout') +}); + // Makes Express use a router called utilities app.use('/api', utilities); -- cgit v1.2.3