mirror of
https://github.com/reality/dbot.git
synced 2024-12-03 17:39:28 +01:00
web changes for posting
This commit is contained in:
parent
d7939a59cc
commit
977de65914
@ -28,7 +28,6 @@ var api = function(dbot) {
|
||||
accessNeeded,
|
||||
allowedNicks;
|
||||
|
||||
console.log('haxess called');
|
||||
if(mConfig.requireWebLogin == true) {
|
||||
if(req.isAuthenticated()) {
|
||||
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();
|
||||
} else {
|
||||
res.redirect('/');
|
||||
|
@ -34,6 +34,18 @@ var webInterface = function(dbot) {
|
||||
|
||||
passport.deserializeUser(function(id, done) {
|
||||
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);
|
||||
});
|
||||
});
|
||||
@ -76,10 +88,10 @@ var webInterface = function(dbot) {
|
||||
for(var p in pages) {
|
||||
if(_.has(pages, p)) {
|
||||
var func = pages[p],
|
||||
mod = func.module;
|
||||
mod = func.module,
|
||||
type = func.type || 'get';
|
||||
|
||||
console.log('adding ' + p);
|
||||
this.app.get(p, this.api.hasAccess, (function(req, resp) {
|
||||
this.app[type](p, this.api.hasAccess, (function(req, resp) {
|
||||
// Crazy shim to seperate module views.
|
||||
var shim = Object.create(resp);
|
||||
shim.render = (function(view, one, two) {
|
||||
|
@ -3,6 +3,7 @@ html(lang='en')
|
||||
head
|
||||
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="/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="/bootstrap/css/bootstrap.min.css")
|
||||
link(rel='stylesheet', type='text/css', href='/styles.css')
|
||||
|
Loading…
Reference in New Issue
Block a user