summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2023-11-29 15:06:51 +0100
committernextcloud-command <nextcloud-command@users.noreply.github.com>2023-11-30 16:26:46 +0000
commit8c5ea73404447fdef973432b5d909646979fccd5 (patch)
treee1966f37f224341b67664e61c2c121d4e1e5b86d /apps/files_sharing
parentbedcbb8ecc175adb0c8664a82d2e28297a7d7510 (diff)
downloadnextcloud-server-8c5ea73404447fdef973432b5d909646979fccd5.tar.gz
nextcloud-server-8c5ea73404447fdef973432b5d909646979fccd5.zip
Improve share logic for enforced password & expiry date
* It's possible for the admin to enforce and expiry date after, some shares have been created. This commit makes possible to update the share with the new admin constraints. * This commit would users to modify enforced expiry to anything within range and less than the enforced limit in the pre-create dialog for public shares. * This commit fixes, unable to update share without updating password. Signed-off-by: fenn-cs <fenn25.fn@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/src/components/SharingEntryLink.vue10
-rw-r--r--apps/files_sharing/src/mixins/SharesMixin.js16
-rw-r--r--apps/files_sharing/src/views/SharingDetailsTab.vue44
3 files changed, 37 insertions, 33 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index 896ca1bbc95..9218d7afe2e 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/apps/files_sharing/src/components/SharingEntryLink.vue
@@ -97,13 +97,13 @@
</NcActionText>
<NcActionInput v-if="pendingExpirationDate"
class="share-link-expire-date"
- :disabled="saving || isExpiryDateEnforced"
+ :disabled="saving"
:is-native-picker="true"
:hide-label="true"
:value="new Date(share.expireDate)"
type="date"
:min="dateTomorrow"
- :max="dateMaxEnforced"
+ :max="maxExpirationDateEnforced"
@input="onExpirationChange">
<!-- let's not submit when picked, the user
might want to still edit or copy the password -->
@@ -302,12 +302,6 @@ export default {
}
return null
},
- dateMaxEnforced() {
- if (this.config.isDefaultExpireDateEnforced) {
- return new Date(new Date().setDate(new Date().getDate() + this.config.defaultExpireDate))
- }
- return null
- },
/**
* Is the current share password protected ?
*
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index 860d1716fe0..41bdf302f7a 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/apps/files_sharing/src/mixins/SharesMixin.js
@@ -132,6 +132,9 @@ export default {
const shareType = this.share.shareType ?? this.share.type
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
},
+ isRemoteShare() {
+ return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
+ },
isShareOwner() {
return this.share && this.share.owner === getCurrentUser().uid
},
@@ -152,6 +155,19 @@ export default {
]
return !bundledPermissions.includes(this.share.permissions)
},
+ maxExpirationDateEnforced() {
+ if (this.isExpiryDateEnforced) {
+ if (this.isPublicShare) {
+ return this.config.defaultExpirationDate
+ }
+ if (this.isRemoteShare) {
+ return this.config.defaultRemoteExpirationDateString
+ }
+ // If it get's here then it must be an internal share
+ return this.config.defaultInternalExpirationDate
+ }
+ return null
+ },
},
methods: {
diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index 4a347404461..580d24eae58 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -70,7 +70,8 @@
</div>
</div>
<div class="sharingTabDetailsView__advanced-control">
- <NcButton type="tertiary"
+ <NcButton id="advancedSectionAccordionAdvancedControl"
+ type="tertiary"
alignment="end-reverse"
@click="advancedSectionAccordionExpanded = !advancedSectionAccordionExpanded">
{{ t('files_sharing', 'Advanced settings') }}
@@ -79,7 +80,11 @@
</template>
</NcButton>
</div>
- <div v-if="advancedSectionAccordionExpanded" class="sharingTabDetailsView__advanced">
+ <div v-if="advancedSectionAccordionExpanded"
+ id="advancedSectionAccordionAdvanced"
+ class="sharingTabDetailsView__advanced"
+ aria-labelledby="advancedSectionAccordionAdvancedControl"
+ role="region">
<section>
<NcInputField v-if="isPublicShare"
:value.sync="share.label"
@@ -406,19 +411,6 @@ export default {
isFolder() {
return this.fileInfo.type === 'dir'
},
- maxExpirationDateEnforced() {
- if (this.isExpiryDateEnforced) {
- if (this.isPublicShare) {
- return this.config.defaultExpirationDate
- }
- if (this.isRemoteShare) {
- return this.config.defaultRemoteExpirationDateString
- }
- // If it get's here then it must be an internal share
- return this.config.defaultInternalExpirationDate
- }
- return null
- },
/**
* @return {boolean}
*/
@@ -457,9 +449,6 @@ export default {
isGroupShare() {
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_GROUP
},
- isRemoteShare() {
- return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
- },
isNewShare() {
return this.share.id === null || this.share.id === undefined
},
@@ -631,6 +620,9 @@ export default {
: translatedPermissions[permission].toLocaleLowerCase(getLanguage()))
.join(', ')
},
+ advancedControlExpandedValue() {
+ return this.advancedSectionAccordionExpanded ? 'true' : 'false'
+ },
},
watch: {
setCustomPermissions(isChecked) {
@@ -707,6 +699,12 @@ export default {
return
}
+ // If there is an enforced expiry date, then existing shares created before enforcement
+ // have no expiry date, hence we set it here.
+ if (!this.isValidShareAttribute(this.share.expireDate) && this.isExpiryDateEnforced) {
+ this.hasExpirationDate = true
+ }
+
if (
this.isValidShareAttribute(this.share.password)
|| this.isValidShareAttribute(this.share.expireDate)
@@ -762,16 +760,12 @@ export default {
if (!this.writeNoteToRecipientIsChecked) {
this.share.note = ''
}
-
if (this.isPasswordProtected) {
- if (this.isValidShareAttribute(this.share.newPassword)) {
+ if (this.hasUnsavedPassword && this.isValidShareAttribute(this.share.newPassword)) {
this.share.password = this.share.newPassword
this.$delete(this.share, 'newPassword')
- } else {
- if (this.isPasswordEnforced) {
- this.passwordError = true
- return
- }
+ } else if (this.isPasswordEnforced && !this.isValidShareAttribute(this.share.password)) {
+ this.passwordError = true
}
} else {
this.share.password = ''