aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/router.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-03-26 13:17:53 +0100
committerDennis Eriksen <dennis.se@gmail.com>2013-03-26 13:17:53 +0100
commit272589ba344c54835ad229086ea947438ec0ef4c (patch)
treec340236fb2025e79644baced58eb9da1c35d6881 /router.js
parentadded FontAwesome (diff)
downloadDivid-272589ba344c54835ad229086ea947438ec0ef4c.tar.gz
moved the routerfile. don't need a folder for one file.
Diffstat (limited to 'router.js')
-rw-r--r--router.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/router.js b/router.js
new file mode 100644
index 0000000..d0442b8
--- /dev/null
+++ b/router.js
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+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' });
+ });
+
+
+ /*
+ * 404 ERROR
+ */
+
+ app.get('*', function(req, res) {
+ res.render('error/404', { title: 'Fant ikke siden' });
+ });
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}