mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
new priv for uploads
This commit is contained in:
@@ -10,7 +10,7 @@ var db = require('./database'),
|
||||
schemaDate, thisSchemaDate,
|
||||
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
latestSchema = Date.UTC(2016, 5, 13);
|
||||
latestSchema = Date.UTC(2016, 6, 12);
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
db.get('schemaDate', function(err, value) {
|
||||
@@ -617,6 +617,46 @@ Upgrade.upgrade = function(callback) {
|
||||
winston.info('[2016/06/13] Store upvotes/downvotes separately skipped!');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2016, 6, 12);
|
||||
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info('[2016/07/12] Giving upload privileges');
|
||||
var privilegesAPI = require('./privileges');
|
||||
var meta = require('./meta');
|
||||
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) {
|
||||
async.eachSeries(cids, function(cid, next) {
|
||||
privilegesAPI.categories.list(cid, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
async.eachSeries(data.groups, function(group, next) {
|
||||
if (group.name === 'guests' && parseInt(meta.config.allowGuestUploads, 10) !== 1) {
|
||||
return next();
|
||||
}
|
||||
if (group.privileges['groups:read']) {
|
||||
privilegesAPI.categories.give(['upload:post:image'], cid, group.name, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}, next);
|
||||
});
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
winston.info('[2016/07/12] Upload privileges done');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
winston.info('[2016/07/12] Upload privileges skipped!');
|
||||
next();
|
||||
}
|
||||
}
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
||||
|
||||
Reference in New Issue
Block a user