diff --git a/modules/web/web.js b/modules/web/web.js index ed4fb3c..c3b8630 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -20,9 +20,17 @@ var webInterface = function(dbot) { this.app.use(passport.initialize()); this.app.use(passport.session()); - this.app.use(app.router); + this.app.use(this.app.router); - passport.use(new LocalStrategy(function(username, pass, callback) { + passport.serializeUser(function(user, done) { + done(null, user); + }); + + passport.deserializeUser(function(obj, done) { + done(null, obj); + }); + + passport.use(new LocalStrategy(function(username, password, callback) { var splitUser = username.split('@'), server = splitUser[1], username = splitUser[0]; @@ -45,7 +53,7 @@ var webInterface = function(dbot) { return callback(null, false, { 'message': 'Unknown user' }); } }.bind(this)); - }.bind(this)); + }.bind(this))); var server = this.app.listen(this.config.webPort); @@ -89,9 +97,9 @@ var webInterface = function(dbot) { }); this.app.get('/login', function(req, res) { - res.render('login', function(req, res) { + res.render('login', { 'user': req.user, - 'message': req.flash('error'); + 'message': req.flash('error') }); }); diff --git a/views/login.jade b/views/login.jade new file mode 100644 index 0000000..66c4020 --- /dev/null +++ b/views/login.jade @@ -0,0 +1,19 @@ +extends layout + +block content + div#backlink + a(href='/') « Home + br + if message + p #{message} + div#login + form(action='/login', method='post') + p + key Username + input(type="text", name="username") + p + key Password + input(type="password", name="password") + p + input(type="submit", value="Log In") +