mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
securing settings.save socket listeners behind admin namespace
This commit is contained in:
@@ -17,7 +17,7 @@ define(function() {
|
|||||||
var Settings = {};
|
var Settings = {};
|
||||||
|
|
||||||
Settings.load = function(hash, formEl) {
|
Settings.load = function(hash, formEl) {
|
||||||
socket.emit('modules.settings.get', {
|
socket.emit('admin.settings.get', {
|
||||||
hash: hash
|
hash: hash
|
||||||
}, function(err, values) {
|
}, function(err, values) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@@ -33,7 +33,7 @@ define(function() {
|
|||||||
if (formEl.length) {
|
if (formEl.length) {
|
||||||
var values = formEl.serializeObject();
|
var values = formEl.serializeObject();
|
||||||
|
|
||||||
socket.emit('modules.settings.set', {
|
socket.emit('admin.settings.set', {
|
||||||
hash: hash,
|
hash: hash,
|
||||||
values: values
|
values: values
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
|
|||||||
@@ -19,7 +19,17 @@ var groups = require('../groups'),
|
|||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
index = require('./index'),
|
index = require('./index'),
|
||||||
|
|
||||||
SocketAdmin = {};
|
SocketAdmin = {
|
||||||
|
topics: {},
|
||||||
|
user: {},
|
||||||
|
categories: {},
|
||||||
|
themes: {},
|
||||||
|
plugins: {},
|
||||||
|
widgets: {},
|
||||||
|
config: {},
|
||||||
|
groups: {},
|
||||||
|
settings: {}
|
||||||
|
};
|
||||||
|
|
||||||
SocketAdmin.before = function(socket, next) {
|
SocketAdmin.before = function(socket, next) {
|
||||||
// Verify administrative privileges
|
// Verify administrative privileges
|
||||||
@@ -61,9 +71,6 @@ SocketAdmin.getVisitorCount = function(socket, data, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Topics */
|
/* Topics */
|
||||||
|
|
||||||
SocketAdmin.topics = {};
|
|
||||||
|
|
||||||
SocketAdmin.topics.getMore = function(socket, data, callback) {
|
SocketAdmin.topics.getMore = function(socket, data, callback) {
|
||||||
if(!data) {
|
if(!data) {
|
||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
@@ -76,9 +83,6 @@ SocketAdmin.topics.getMore = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* User */
|
/* User */
|
||||||
|
|
||||||
SocketAdmin.user = {};
|
|
||||||
|
|
||||||
SocketAdmin.user.makeAdmin = function(socket, theirid) {
|
SocketAdmin.user.makeAdmin = function(socket, theirid) {
|
||||||
admin.user.makeAdmin(socket.uid, theirid, socket);
|
admin.user.makeAdmin(socket.uid, theirid, socket);
|
||||||
};
|
};
|
||||||
@@ -136,9 +140,6 @@ SocketAdmin.user.search = function(socket, username, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Categories */
|
/* Categories */
|
||||||
|
|
||||||
SocketAdmin.categories = {};
|
|
||||||
|
|
||||||
SocketAdmin.categories.create = function(socket, data, callback) {
|
SocketAdmin.categories.create = function(socket, data, callback) {
|
||||||
if(!data) {
|
if(!data) {
|
||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
@@ -290,11 +291,6 @@ SocketAdmin.categories.groupsList = function(socket, cid, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Themes, Widgets, and Plugins */
|
/* Themes, Widgets, and Plugins */
|
||||||
|
|
||||||
SocketAdmin.themes = {};
|
|
||||||
SocketAdmin.plugins = {};
|
|
||||||
SocketAdmin.widgets = {};
|
|
||||||
|
|
||||||
SocketAdmin.themes.getInstalled = function(socket, data, callback) {
|
SocketAdmin.themes.getInstalled = function(socket, data, callback) {
|
||||||
meta.themes.get(callback);
|
meta.themes.get(callback);
|
||||||
};
|
};
|
||||||
@@ -325,9 +321,6 @@ SocketAdmin.widgets.set = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Configs */
|
/* Configs */
|
||||||
|
|
||||||
SocketAdmin.config = {};
|
|
||||||
|
|
||||||
SocketAdmin.config.get = function(socket, data, callback) {
|
SocketAdmin.config.get = function(socket, data, callback) {
|
||||||
meta.configs.list(callback);
|
meta.configs.list(callback);
|
||||||
};
|
};
|
||||||
@@ -358,9 +351,6 @@ SocketAdmin.config.remove = function(socket, key) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Groups */
|
/* Groups */
|
||||||
|
|
||||||
SocketAdmin.groups = {};
|
|
||||||
|
|
||||||
SocketAdmin.groups.create = function(socket, data, callback) {
|
SocketAdmin.groups.create = function(socket, data, callback) {
|
||||||
if(!data) {
|
if(!data) {
|
||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
@@ -409,4 +399,14 @@ SocketAdmin.groups.update = function(socket, data, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Settings */
|
||||||
|
SocketAdmin.settings.get = function(socket, data, callback) {
|
||||||
|
meta.settings.get(data.hash, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
SocketAdmin.settings.set = function(socket, data, callback) {
|
||||||
|
console.log('setting', data);
|
||||||
|
meta.settings.set(data.hash, data.values, callback);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = SocketAdmin;
|
module.exports = SocketAdmin;
|
||||||
|
|||||||
@@ -245,14 +245,4 @@ SocketModules.sounds.getMapping = function(socket, data, callback) {
|
|||||||
meta.sounds.getMapping(callback);
|
meta.sounds.getMapping(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Settings */
|
|
||||||
SocketModules.settings.get = function(socket, data, callback) {
|
|
||||||
meta.settings.get(data.hash, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketModules.settings.set = function(socket, data, callback) {
|
|
||||||
console.log('setting', data);
|
|
||||||
meta.settings.set(data.hash, data.values, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = SocketModules;
|
module.exports = SocketModules;
|
||||||
Reference in New Issue
Block a user