web changes for posting

This commit is contained in:
reality 2014-10-21 21:25:50 +00:00
parent d7939a59cc
commit 977de65914
3 changed files with 17 additions and 5 deletions

View File

@ -28,7 +28,6 @@ var api = function(dbot) {
accessNeeded, accessNeeded,
allowedNicks; allowedNicks;
console.log('haxess called');
if(mConfig.requireWebLogin == true) { if(mConfig.requireWebLogin == true) {
if(req.isAuthenticated()) { if(req.isAuthenticated()) {
if(_.has(mConfig, 'pageAccess') && _.has(mConfig.pageAccess, path)) { if(_.has(mConfig, 'pageAccess') && _.has(mConfig.pageAccess, path)) {
@ -49,7 +48,7 @@ console.log('haxess called');
} }
} }
if(_.include(allowedUsers, req.user.primaryNick)) { if(_.include(accessNeeded(), req.user.primaryNick)) {
return next(); return next();
} else { } else {
res.redirect('/'); res.redirect('/');

View File

@ -34,6 +34,18 @@ var webInterface = function(dbot) {
passport.deserializeUser(function(id, done) { passport.deserializeUser(function(id, done) {
dbot.api.users.getUser(id, function(err, user) { dbot.api.users.getUser(id, function(err, user) {
// Get user access level. Sigh.
if(user) {
user.access = 'user';
if(_.include(dbot.config.admins, user.primaryNick)) {
user.access = 'admin';
} else if(_.include(dbot.config.moderators, user.primaryNick)) {
user.access = 'moderator';
} else if(_.include(dbot.config.power_users, user.primaryNick)) {
user.access = 'power_user';
}
}
console.log(user);
done(null, user); done(null, user);
}); });
}); });
@ -76,10 +88,10 @@ var webInterface = function(dbot) {
for(var p in pages) { for(var p in pages) {
if(_.has(pages, p)) { if(_.has(pages, p)) {
var func = pages[p], var func = pages[p],
mod = func.module; mod = func.module,
type = func.type || 'get';
console.log('adding ' + p); this.app[type](p, this.api.hasAccess, (function(req, resp) {
this.app.get(p, this.api.hasAccess, (function(req, resp) {
// Crazy shim to seperate module views. // Crazy shim to seperate module views.
var shim = Object.create(resp); var shim = Object.create(resp);
shim.render = (function(view, one, two) { shim.render = (function(view, one, two) {

View File

@ -3,6 +3,7 @@ html(lang='en')
head head
meta(charset='utf-8') meta(charset='utf-8')
script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js") script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js")
script(type="text/javascript", src="/fs_edit.js")
link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro") link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro")
link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css") link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css")
link(rel='stylesheet', type='text/css', href='/styles.css') link(rel='stylesheet', type='text/css', href='/styles.css')