Skip to content

Commit 29f9a8a

Browse files
danxuliubackportbot[bot]
authored andcommitted
Fix share permission checkboxes enabled when permissions can not be set
A sharee can reshare a file and set the edit, create, delete and share permissions of the reshare only if the received share has edit, create, delete and share permissions, or if they were revoked in the received share after being set in the reshare. Therefore, the permission checkboxes in the share menu should be enabled only if the user can set them (otherwise trying to check them will lead to an error). Note that "sharePermissions" has all the permissions if the file is not a reshare but a file owned by the user. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent 047b540 commit 29f9a8a

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
ref="canEdit"
4040
:checked.sync="canEdit"
4141
:value="permissionsEdit"
42-
:disabled="saving">
42+
:disabled="saving || !canSetEdit">
4343
{{ t('files_sharing', 'Allow editing') }}
4444
</ActionCheckbox>
4545

@@ -49,7 +49,7 @@
4949
ref="canCreate"
5050
:checked.sync="canCreate"
5151
:value="permissionsCreate"
52-
:disabled="saving">
52+
:disabled="saving || !canSetCreate">
5353
{{ t('files_sharing', 'Allow creating') }}
5454
</ActionCheckbox>
5555

@@ -59,7 +59,7 @@
5959
ref="canDelete"
6060
:checked.sync="canDelete"
6161
:value="permissionsDelete"
62-
:disabled="saving">
62+
:disabled="saving || !canSetDelete">
6363
{{ t('files_sharing', 'Allow deleting') }}
6464
</ActionCheckbox>
6565

@@ -68,7 +68,7 @@
6868
ref="canReshare"
6969
:checked.sync="canReshare"
7070
:value="permissionsShare"
71-
:disabled="saving">
71+
:disabled="saving || !canSetReshare">
7272
{{ t('files_sharing', 'Allow resharing') }}
7373
</ActionCheckbox>
7474

@@ -215,6 +215,54 @@ export default {
215215
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
216216
},
217217
218+
/**
219+
* Can the sharer set whether the sharee can edit the file ?
220+
*
221+
* @returns {boolean}
222+
*/
223+
canSetEdit() {
224+
// If the owner revoked the permission after the resharer granted it
225+
// the share still has the permission, and the resharer is still
226+
// allowed to revoke it too (but not to grant it again).
227+
return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit
228+
},
229+
230+
/**
231+
* Can the sharer set whether the sharee can create the file ?
232+
*
233+
* @returns {boolean}
234+
*/
235+
canSetCreate() {
236+
// If the owner revoked the permission after the resharer granted it
237+
// the share still has the permission, and the resharer is still
238+
// allowed to revoke it too (but not to grant it again).
239+
return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate
240+
},
241+
242+
/**
243+
* Can the sharer set whether the sharee can delete the file ?
244+
*
245+
* @returns {boolean}
246+
*/
247+
canSetDelete() {
248+
// If the owner revoked the permission after the resharer granted it
249+
// the share still has the permission, and the resharer is still
250+
// allowed to revoke it too (but not to grant it again).
251+
return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete
252+
},
253+
254+
/**
255+
* Can the sharer set whether the sharee can reshare the file ?
256+
*
257+
* @returns {boolean}
258+
*/
259+
canSetReshare() {
260+
// If the owner revoked the permission after the resharer granted it
261+
// the share still has the permission, and the resharer is still
262+
// allowed to revoke it too (but not to grant it again).
263+
return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare
264+
},
265+
218266
/**
219267
* Can the sharee edit the shared file ?
220268
*/

0 commit comments

Comments
 (0)