pull/5221/merge
Lucas Aymon 2 weeks ago committed by GitHub
commit f60b26c231
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -55,6 +55,15 @@ module.exports = {
parentId: parentFolderId,
slug: folderSlug
}).first()
const hierarchy = parentFolderId ? await WIKI.models.assetFolders.getHierarchy(parentFolderId) : []
// Check target folder permissions
const folderTargetPath = parentFolderId ? hierarchy.map(h => h.slug).join('/') + `/${folderSlug}` : folderSlug
if (!WIKI.auth.checkAccess(context.req.user, ['write:assets'], { path: folderTargetPath })) {
throw new WIKI.Error.AssetCreateFolderForbidden()
}
if (!result) {
await WIKI.models.assetFolders.query().insert({
slug: folderSlug,

@ -1,6 +1,10 @@
const CustomError = require('custom-error-instance')
module.exports = {
AssetCreateFolderForbidden: CustomError('AssetCreateFolderForbidden', {
message: 'You are not authorized to create this folder.',
code: 2010
}),
AssetDeleteForbidden: CustomError('AssetDeleteForbidden', {
message: 'You are not authorized to delete this asset.',
code: 2003

Loading…
Cancel
Save