Skip to content

Commit 344638f

Browse files
committed
fix: only allow modifying sharing to form owners
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent 18a5278 commit 344638f

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
keep-open
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 …')"
@@ -46,6 +46,11 @@ export default {
4646
type: Boolean,
4747
required: true,
4848
},
49+
50+
isCurrentUserOwner: {
51+
type: Boolean,
52+
required: true,
53+
},
4954
},
5055
5156
computed: {

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
:model-value="canEditForm"
@@ -80,6 +80,11 @@ export default {
8080
type: Boolean,
8181
required: true,
8282
},
83+
84+
isCurrentUserOwner: {
85+
type: Boolean,
86+
required: true,
87+
},
8388
},
8489
8590
computed: {

src/components/SidebarTabs/SharingSidebarTab.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:current-shares="form.shares"
2121
:show-loading="isLoading"
2222
:locked="locked"
23+
:is-current-user-owner="isCurrentUserOwner"
2324
@add-share="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
close-after-click
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
:checked="form.access.permitAllUsers"
163-
:disabled="locked"
168+
:disabled="locked || !isCurrentUserOwner"
164169
type="switch"
165170
@update:checked="onPermitAllUsersChange" />
166171
</div>
@@ -176,7 +181,7 @@
176181
<NcCheckboxRadioSwitch
177182
id="share-switch__show-to-all"
178183
:checked="form.access.showToAllUsers"
179-
:disabled="locked"
184+
:disabled="locked || !isCurrentUserOwner"
180185
type="switch"
181186
@update:checked="onShowToAllUsersChange" />
182187
</div>
@@ -189,13 +194,15 @@
189194
:key="'share-' + share.shareType + '-' + share.shareWith"
190195
:share="share"
191196
:locked="locked"
197+
:is-current-user-owner="isCurrentUserOwner"
192198
@remove-share="removeShare"
193199
@update:share="updateShare" />
194200
</TransitionGroup>
195201
</div>
196202
</template>
197203

198204
<script>
205+
import { getCurrentUser } from '@nextcloud/auth'
199206
import { generateOcsUrl } from '@nextcloud/router'
200207
import { loadState } from '@nextcloud/initial-state'
201208
import { showError } from '@nextcloud/dialogs'
@@ -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)