mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
it fucking works (web login that is) [#538]
This commit is contained in:
parent
12e11e78c1
commit
3788aa9399
@ -30,7 +30,11 @@ var pages = function(dbot) {
|
|||||||
/* TODO: merge back into github module */
|
/* TODO: merge back into github module */
|
||||||
var milestones;
|
var milestones;
|
||||||
request({"url":"https://api.github.com/repos/" + dbot.config.modules.github.defaultrepo + "/milestones?state=open","headers":{"User-Agent":"reality/depressionbot (project module)"}}, function(error, response, body){
|
request({"url":"https://api.github.com/repos/" + dbot.config.modules.github.defaultrepo + "/milestones?state=open","headers":{"User-Agent":"reality/depressionbot (project module)"}}, function(error, response, body){
|
||||||
|
try {
|
||||||
milestones = JSON.parse(body);
|
milestones = JSON.parse(body);
|
||||||
|
} catch(err) {
|
||||||
|
milestones = {};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"webHost": "nourishedcloud.com",
|
"webHost": "nourishedcloud.com",
|
||||||
"webPort": 8080,
|
"webPort": 8080,
|
||||||
"externalPath": false
|
"externalPath": false,
|
||||||
|
"dbType": "redis"
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ var webInterface = function(dbot) {
|
|||||||
this.app.use(express.static(this.pub));
|
this.app.use(express.static(this.pub));
|
||||||
this.app.set('view engine', 'jade');
|
this.app.set('view engine', 'jade');
|
||||||
this.app.use(express.cookieParser());
|
this.app.use(express.cookieParser());
|
||||||
|
this.app.use(express.bodyParser());
|
||||||
this.app.use(express.methodOverride());
|
this.app.use(express.methodOverride());
|
||||||
this.app.use(express.session({ 'secret': 'wat' }));
|
this.app.use(express.session({ 'secret': 'wat' }));
|
||||||
this.app.use(flash());
|
this.app.use(flash());
|
||||||
@ -39,8 +40,7 @@ var webInterface = function(dbot) {
|
|||||||
if(user) {
|
if(user) {
|
||||||
this.api.getWebUser(user.id, function(webUser) {
|
this.api.getWebUser(user.id, function(webUser) {
|
||||||
if(webUser) {
|
if(webUser) {
|
||||||
var hash = passHash.generate(pass);
|
if(passHash.verify(password, webUser.password)) {
|
||||||
if(webUser.password === hash) {
|
|
||||||
return callback(null, user);
|
return callback(null, user);
|
||||||
} else {
|
} else {
|
||||||
return callback(null, false, { 'message': 'Incorrect password.' });
|
return callback(null, false, { 'message': 'Incorrect password.' });
|
||||||
@ -107,7 +107,10 @@ var webInterface = function(dbot) {
|
|||||||
'failureRedirect': '/login',
|
'failureRedirect': '/login',
|
||||||
'failureFlash': true
|
'failureFlash': true
|
||||||
}), function(req, res) {
|
}), function(req, res) {
|
||||||
res.redirect('/');
|
res.render('login', {
|
||||||
|
'user': req.user,
|
||||||
|
'message': 'Successfully logged in!'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.app.get('/logout', function(req, res) {
|
this.app.get('/logout', function(req, res) {
|
||||||
@ -130,16 +133,17 @@ var webInterface = function(dbot) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'getWebUser': function(id) {
|
'getWebUser': function(id, callback) {
|
||||||
this.db.read('web_users', id, function(err, webUser) {
|
this.db.read('web_users', id, function(err, webUser) {
|
||||||
if(!err) callback(webUser);
|
callback(webUser);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.commands = {
|
this.commands = {
|
||||||
'~setwebpassword': function(event) {
|
'~setwebpass': function(event) {
|
||||||
var newPass = event.input[1];
|
var newPass = event.input[1];
|
||||||
|
console.log(newPass);
|
||||||
this.api.getWebUser(event.rUser.id, function(webUser) {
|
this.api.getWebUser(event.rUser.id, function(webUser) {
|
||||||
if(!webUser) {
|
if(!webUser) {
|
||||||
webUser = {
|
webUser = {
|
||||||
@ -152,9 +156,10 @@ var webInterface = function(dbot) {
|
|||||||
this.db.save('web_users', webUser.id, webUser, function(result) {
|
this.db.save('web_users', webUser.id, webUser, function(result) {
|
||||||
event.reply(dbot.t('web_pass_set'));
|
event.reply(dbot.t('web_pass_set'));
|
||||||
});
|
});
|
||||||
});
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.commands['~setwebpass'].regex = [/^~setwebpass ([^ ]+)$/, 2]
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fetch = function(dbot) {
|
exports.fetch = function(dbot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user