Skip to content

Commit

Permalink
check permission before delete image
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwenxuan authored and zhouwenxuan committed Feb 18, 2025
1 parent 4253e3b commit d594dfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions frontend/src/components/dirent-grid-view/dirent-grid-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,13 +859,16 @@ class DirentGridView extends React.Component {
let direntPath = Utils.joinPath(path, dirent.name);

let canModifyFile = false;
let canDeleteFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canModifyFile = true;
canDeleteFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
const { modify, delete: canDelete } = customPermission.permission;
canModifyFile = modify;
canDeleteFile = canDelete;
}
}

Expand Down Expand Up @@ -1044,7 +1047,7 @@ class DirentGridView extends React.Component {
closeImagePopup={this.closeImagePopup}
moveToPrevImage={this.moveToPrevImage}
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
onDeleteImage={(canDeleteFile && this.deleteImage) ? this.deleteImage : null}
onRotateImage={this.rotateImage}
enableRotate={canModifyFile}
/>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/dirent-list-view/dirent-list-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,16 @@ class DirentListView extends React.Component {
const isDesktop = Utils.isDesktop();

let canModifyFile = false;
let canDeleteFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canModifyFile = true;
canDeleteFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
const { modify, delete: canDelete } = customPermission.permission;
canModifyFile = modify;
canDeleteFile = canDelete;
}
}

Expand Down Expand Up @@ -874,7 +877,7 @@ class DirentListView extends React.Component {
closeImagePopup={this.closeImagePopup}
moveToPrevImage={this.moveToPrevImage}
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
onDeleteImage={(canDeleteFile && this.deleteImage) ? this.deleteImage : null}
onRotateImage={this.rotateImage}
enableRotate={canModifyFile}
/>
Expand Down

0 comments on commit d594dfe

Please sign in to comment.