3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +01:00

some other stuff and the login view. there is some stupid issue picking up the credentials from the form though idk

This commit is contained in:
reality 2013-07-27 18:14:00 +00:00
parent f53b826307
commit 12e11e78c1
2 changed files with 32 additions and 5 deletions

View File

@ -20,9 +20,17 @@ var webInterface = function(dbot) {
this.app.use(passport.initialize()); this.app.use(passport.initialize());
this.app.use(passport.session()); 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('@'), var splitUser = username.split('@'),
server = splitUser[1], server = splitUser[1],
username = splitUser[0]; username = splitUser[0];
@ -45,7 +53,7 @@ var webInterface = function(dbot) {
return callback(null, false, { 'message': 'Unknown user' }); return callback(null, false, { 'message': 'Unknown user' });
} }
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this)));
var server = this.app.listen(this.config.webPort); var server = this.app.listen(this.config.webPort);
@ -89,9 +97,9 @@ var webInterface = function(dbot) {
}); });
this.app.get('/login', function(req, res) { this.app.get('/login', function(req, res) {
res.render('login', function(req, res) { res.render('login', {
'user': req.user, 'user': req.user,
'message': req.flash('error'); 'message': req.flash('error')
}); });
}); });

19
views/login.jade Normal file
View File

@ -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")