Skip to content

Commit 7c61071

Browse files
authored
Merge pull request #3308 from nextcloud/fix/disable-sharing-actions
fix: only allow modifying of sharing to form owners
2 parents 804f692 + b2ced1a commit 7c61071

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/components/SidebarTabs/SharingSearchDiv.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NcSelectUsers
99
keepOpen
1010
:loading="showLoadingCircle"
11-
:disabled="locked"
11+
:disabled="locked || !isCurrentUserOwner"
1212
:options="options"
1313
:placeholder="t('forms', 'Search for user, group or team …')"
1414
:aria-label-listbox="t('forms', 'Search for user, group or team …')"
@@ -47,6 +47,11 @@ export default {
4747
type: Boolean,
4848
required: true,
4949
},
50+
51+
isCurrentUserOwner: {
52+
type: Boolean,
53+
required: true,
54+
},
5055
},
5156
5257
emits: ['addShare'],

src/components/SidebarTabs/SharingShareDiv.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<span>{{ displayName }}</span>
1515
<span>{{ displayNameAppendix }}</span>
1616
</div>
17-
<NcActions class="share-div__actions">
17+
<NcActions class="share-div__actions" :disabled="!isCurrentUserOwner">
1818
<NcActionCaption :name="t('forms', 'Permissions')" />
1919
<NcActionCheckbox
2020
:modelValue="canEditForm"
@@ -79,6 +79,11 @@ export default {
7979
type: Boolean,
8080
required: true,
8181
},
82+
83+
isCurrentUserOwner: {
84+
type: Boolean,
85+
required: true,
86+
},
8287
},
8388
8489
emits: ['removeShare', 'update:share'],

src/components/SidebarTabs/SharingSidebarTab.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:currentShares="form.shares"
2121
:showLoading="isLoading"
2222
:locked="locked"
23+
:isCurrentUserOwner="isCurrentUserOwner"
2324
@addShare="addShare" />
2425

2526
<!-- Public Link -->
@@ -31,7 +32,9 @@
3132
</div>
3233
<span class="share-div__desc">{{ t('forms', 'Share link') }}</span>
3334
<NcActions>
34-
<NcActionButton :disabled="locked" @click="addPublicLink">
35+
<NcActionButton
36+
:disabled="locked || !isCurrentUserOwner"
37+
@click="addPublicLink">
3538
<template #icon>
3639
<IconPlus :size="20" />
3740
</template>
@@ -80,15 +83,17 @@
8083
</NcActionButton>
8184
<NcActionButton
8285
v-else
83-
:disabled="locked"
86+
:disabled="locked || !isCurrentUserOwner"
8487
@click="makeEmbeddable(share)">
8588
<template #icon>
8689
<IconLinkBoxVariantOutline :size="20" />
8790
</template>
8891
<!-- TRANSLATORS: This means the link can be embedded into external websites -->
8992
{{ t('forms', 'Convert to embeddable link') }}
9093
</NcActionButton>
91-
<NcActionButton :disabled="locked" @click="removeShare(share)">
94+
<NcActionButton
95+
:disabled="locked || !isCurrentUserOwner"
96+
@click="removeShare(share)">
9297
<template #icon>
9398
<IconDelete :size="20" />
9499
</template>
@@ -97,7 +102,7 @@
97102
<NcActionButton
98103
v-if="appConfig.allowPublicLink"
99104
closeAfterClick
100-
:disabled="locked"
105+
:disabled="locked || !isCurrentUserOwner"
101106
@click="addPublicLink">
102107
<template #icon>
103108
<IconPlus :size="20" />
@@ -160,7 +165,7 @@
160165
<NcCheckboxRadioSwitch
161166
id="share-switch__permit-all"
162167
:modelValue="form.access.permitAllUsers"
163-
:disabled="locked"
168+
:disabled="locked || !isCurrentUserOwner"
164169
type="switch"
165170
@update:modelValue="onPermitAllUsersChange" />
166171
</div>
@@ -176,7 +181,7 @@
176181
<NcCheckboxRadioSwitch
177182
id="share-switch__show-to-all"
178183
:modelValue="form.access.showToAllUsers"
179-
:disabled="locked"
184+
:disabled="locked || !isCurrentUserOwner"
180185
type="switch"
181186
@update:modelValue="onShowToAllUsersChange" />
182187
</div>
@@ -189,13 +194,15 @@
189194
:key="'share-' + share.shareType + '-' + share.shareWith"
190195
:share="share"
191196
:locked="locked"
197+
:isCurrentUserOwner="isCurrentUserOwner"
192198
@removeShare="removeShare"
193199
@update:share="updateShare" />
194200
</TransitionGroup>
195201
</div>
196202
</template>
197203

198204
<script>
205+
import { getCurrentUser } from '@nextcloud/auth'
199206
import axios from '@nextcloud/axios'
200207
import { showError } from '@nextcloud/dialogs'
201208
import { loadState } from '@nextcloud/initial-state'
@@ -274,6 +281,10 @@ export default {
274281
},
275282
276283
computed: {
284+
isCurrentUserOwner() {
285+
return getCurrentUser().uid === this.form.ownerId
286+
},
287+
277288
sortedShares() {
278289
// Remove Link-Shares, which are handled separately, then sort
279290
return this.form.shares

0 commit comments

Comments
 (0)