From f53b8263079e1e9f66d454c569f008833940e688 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 27 Jul 2013 17:31:00 +0000 Subject: [PATCH] login and logout web routes [#538] --- modules/web/web.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/web/web.js b/modules/web/web.js index 8841947..ed4fb3c 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -89,7 +89,22 @@ var webInterface = function(dbot) { }); this.app.get('/login', function(req, res) { - + res.render('login', function(req, res) { + 'user': req.user, + 'message': req.flash('error'); + }); + }); + + this.app.post('/login', passport.authenticate('local', { + 'failureRedirect': '/login', + 'failureFlash': true + }), function(req, res) { + res.redirect('/'); + }); + + this.app.get('/logout', function(req, res) { + req.logout(); + res.redirect('/'); }); }.bind(this);