aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/routes/router.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-03-26 11:25:57 +0100
committerDennis Eriksen <dennis.se@gmail.com>2013-03-26 11:25:57 +0100
commitb2f37bdcb03d93a80254f58694f8047d3c35b9bb (patch)
treedcb79d880376490de8074d249bb67ed471b60629 /routes/router.js
parentold commit (diff)
downloadDivid-b2f37bdcb03d93a80254f58694f8047d3c35b9bb.tar.gz
changed the way the app handles routes. now everything goes straight to
router.js, insted of being partially handled in app.js
Diffstat (limited to 'routes/router.js')
-rw-r--r--routes/router.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/routes/router.js b/routes/router.js
new file mode 100644
index 0000000..11d45bb
--- /dev/null
+++ b/routes/router.js
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+module.exports = function(app) {
+ /*
+ * GET home page.
+ *
+ * '/'
+ */
+
+ app.get('/', function(req, res){
+ // check if the user's credentials are saved in a cookie
+ if (req.cookies.user == undefined || req.cookies.pass == undefined) {
+ res.render('index', { title: 'DERS' });
+ } else { // appempt automatic login
+ AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) {
+ if (o != null) {
+ req.session.user = o;
+ res.redirect('/account');
+ } else {
+ res.render('index', { title: 'DERS' });
+ }
+ });
+ }
+ });
+
+
+ /*
+ * GET login page
+ *
+ * '/login'
+ */
+
+ app.get('/login', function(req, res) {
+ res.render('login', { title: 'Logg inn' });
+ });
+
+
+}