diff --git a/routes/.js b/routes/.js index f9a6b99..19e05ca 100644 --- a/routes/.js +++ b/routes/.js @@ -4,9 +4,11 @@ const router = express.Router(); // GET /login router.get('/', (req, res) => { - res.send("Test") + if (req.session.user) return res.redirect('/dashboard'); + res.redirect('/login'); // Assumes you have a 'login' view/template }); module.exports = router; -// I genuinely have no clue if this'll work.... but hey, it's worth a shot. \ No newline at end of file +// I genuinely have no clue if this'll work.... but hey, it's worth a shot. +// It worked, so yea. \ No newline at end of file diff --git a/routes/dashboard.js b/routes/dashboard.js new file mode 100644 index 0000000..932a0fa --- /dev/null +++ b/routes/dashboard.js @@ -0,0 +1,14 @@ +const express = require('express'); +const db = global.db; +const router = express.Router(); + +// GET /login +router.get('/', (req, res) => { + if (!req.session.user) return res.redirect('/login'); + return res.render("dashboard", { sessionData: req.session }); +}); + +module.exports = router; + +// I genuinely have no clue if this'll work.... but hey, it's worth a shot. +// It worked, so yea. \ No newline at end of file diff --git a/views/dashboard.ejs b/views/dashboard.ejs new file mode 100644 index 0000000..b603901 --- /dev/null +++ b/views/dashboard.ejs @@ -0,0 +1,61 @@ + + + + + Dashboard + + + +
+
Dashboard
+
+
+ +
+
+ +
+
+ +
+
+
+ + \ No newline at end of file