From fe66922627fdbdda8baaf1720daecae98c35fd45 Mon Sep 17 00:00:00 2001 From: baoliang Date: Mon, 29 Jan 2018 15:45:42 +0800 Subject: [PATCH] metadata --- model/sjy_eco_v1.js | 4 ++++ package.json | 1 + routes/login.js | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/model/sjy_eco_v1.js b/model/sjy_eco_v1.js index a39be55..c5919bd 100644 --- a/model/sjy_eco_v1.js +++ b/model/sjy_eco_v1.js @@ -15,3 +15,7 @@ exports.getLast10Metadata = function () { return db.any('select id, uuid, title, description, ts_created from metadata order by ts_created desc limit 10') }; +exports.login = function(name, password) { + +} + diff --git a/package.json b/package.json index 874ed6f..2832608 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "node ./bin/www" }, "dependencies": { + "bcrypt": "^1.0.3", "bluebird": "^3.4.7", "body-parser": "~1.15.2", "bootstrap": "^3.3.7", diff --git a/routes/login.js b/routes/login.js index ea21cf4..a73e791 100644 --- a/routes/login.js +++ b/routes/login.js @@ -10,4 +10,14 @@ router.get('/', function (req, res, next) { }); }); +router.post('/', function(req, res, next) { + if (req.body.username && req.body.username === 'user' && req.body.password && req.body.password === 'pass') { + req.session.authenticated = true; + res.redirect('/secure'); + } else { + req.flash('error', 'Username and password are incorrect'); + res.redirect('/login'); + } +}); + module.exports = router;