diff options
Diffstat (limited to '')
-rw-r--r-- | modules/account-manager.js | 2 | ||||
-rw-r--r-- | router.js | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/modules/account-manager.js b/modules/account-manager.js index 6c9f753..b9cb1f9 100644 --- a/modules/account-manager.js +++ b/modules/account-manager.js @@ -6,7 +6,7 @@ var moment = require('moment'); var dbPort = 27017; var dbHost = 'localhost'; -var dbName = 'node-login'; +var dbName = 'DERStest'; /* establish the database connection */ @@ -37,7 +37,16 @@ module.exports = function(app) { */ app.get('/login', function(req, res) { - res.render('login', { title: 'Logg inn' }); + if (req.cookies.user == undefined || req.cookies.pass == undefined) { + res.render('login', { title: 'Logg inn' }); + } else { + AM.autoLogin(req.cookies.user, req.cookies.pass, function(o) { + if (o != null) { + req.session.user = o; + res.redirect('/account'); + } else { res.render('login', { title: 'Logg inn' }); } + }); + } }); |