make upload permissions global

give upload image permission to registered users on install
add global privileges to app.user.privileges for client side use
This commit is contained in:
Barış Soner Uşaklı
2018-01-03 13:27:30 -05:00
parent bf1e2cfe46
commit ff6c6a54c1
17 changed files with 179 additions and 56 deletions

View File

@@ -37,9 +37,6 @@ uploadsController.upload = function (req, res, filesIterator) {
uploadsController.uploadPost = function (req, res, next) {
uploadsController.upload(req, res, function (uploadedFile, next) {
if (!parseInt(req.body.cid, 10)) {
return next(new Error('[[error:category-not-selected]]'));
}
var isImage = uploadedFile.type.match(/image./);
if (isImage) {
uploadAsImage(req, uploadedFile, next);
@@ -52,7 +49,7 @@ uploadsController.uploadPost = function (req, res, next) {
function uploadAsImage(req, uploadedFile, callback) {
async.waterfall([
function (next) {
privileges.categories.can('upload:post:image', req.body.cid, req.uid, next);
privileges.global.can('upload:post:image', req.uid, next);
},
function (canUpload, next) {
if (!canUpload) {
@@ -82,7 +79,7 @@ function uploadAsImage(req, uploadedFile, callback) {
function uploadAsFile(req, uploadedFile, callback) {
async.waterfall([
function (next) {
privileges.categories.can('upload:post:file', req.body.cid, req.uid, next);
privileges.global.can('upload:post:file', req.uid, next);
},
function (canUpload, next) {
if (!canUpload) {