diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-08 10:42:28 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-08 10:42:28 +0200 |
commit | 143918fbb939d4b1fd1d0df5439957700dcce9ad (patch) | |
tree | 66cf6be043273a8ef5266dbb1cccabb196307de8 | |
parent | derp (diff) | |
download | Divid-143918fbb939d4b1fd1d0df5439957700dcce9ad.tar.gz |
started on dashboard
Diffstat (limited to '')
-rw-r--r-- | router.js | 38 | ||||
-rw-r--r-- | views/login.ejs | 2 |
2 files changed, 34 insertions, 6 deletions
@@ -31,6 +31,34 @@ module.exports = function(app) { /* + * GET dashboard + * + * '/dashboard' + */ + + app.get('/dashboard', function(req, res) { + if (req.session.user == undefined) { + if (req.cookies.user == undefined || req.cookies.pass == undefined) { + res.redirect('/login'); + } else { + AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) { + req.session.user = o; + res.redirect('/dashboard'); + }); + } + res.redirect('/login'); + } else { + if (req.cookies.user == undefined || req.cookies.pass == undefined) { + res.render('index', { title: 'waaaat' }); + } else { + res.render('index', { title: 'mordi' }); + } + } + }); + + + + /* * GET login page * * '/login' @@ -43,7 +71,7 @@ module.exports = function(app) { AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) { if (o != null) { req.session.user = o; - res.redirect('/account'); + res.redirect('/dashboard'); } else { res.render('login', { title: 'Logg inn' }); } }); } @@ -58,11 +86,11 @@ module.exports = function(app) { res.send(e, 400); } else { req.session.user = o; - if (req.param('remember-me') == 'true') { - res.cookie('user', o.user, { maxAge: 900000 }); - res.cookieI('pass', o.pass, { maxAge: 90000 }); + if (req.param('remember-me') == 'on') { + res.cookie('user', o.user, { maxAge: 900000000 }); + res.cookie('pass', o.pass, { maxAge: 900000000 }); } - res.send(o, 200); + res.redirect('/dashboard'); } }); }); diff --git a/views/login.ejs b/views/login.ejs index 2997d9e..c0c542d 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -12,7 +12,7 @@ <input type="password" name="pass" id="pass-tf" class="span4 required"> <button type="submit" id="btn-login" class="btn btn-primary"><i class="icon-lock icon-white"></i>Sign in</button> <label id="remember-me" class="checkbox">Remember Me - <input type="checkbox" checked="checked"> + <input name="remember-me" type="checkbox" checked="checked"> </label> <div class="clear-fix"></div> <hr> |