diff options
Diffstat (limited to '')
-rw-r--r-- | csci4131/hw6/strap012_hw6/index.js | 16 |
1 files changed, 12 insertions, 4 deletions
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); |