Skip to content

Commit

Permalink
Merge pull request #40933 from nextcloud/check-datemax-enforcement-pu…
Browse files Browse the repository at this point in the history
…bshare

Check expiry enforcement for all share types
  • Loading branch information
come-nc authored Oct 23, 2023
2 parents 73a6061 + 8dfcf2e commit 6114364
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
4 changes: 2 additions & 2 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export default {
return this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced
return this.config.isDefaultRemoteExpireDateEnforced
}
return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
return this.config.isDefaultInternalExpireDateEnforced
},
hasCustomPermissions() {
const bundledPermissions = [
Expand Down
41 changes: 19 additions & 22 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,7 @@ export default {
*/
hasExpirationDate: {
get() {
const isDefaultExpireDateEnabled = this.config.isDefaultExpireDateEnabled
const hasExistingExpirationDate = !!this.share.expireDate || isDefaultExpireDateEnabled
const isDefaultInternalExpireDateEnabled = this.config.isDefaultInternalExpireDateEnabled
const isDefaultRemoteExpireDateEnabled = this.config.isDefaultRemoteExpireDateEnabled
if (this.isPublicShare) {
return hasExistingExpirationDate
}
if (this.isRemoteShare) {
return hasExistingExpirationDate || isDefaultRemoteExpireDateEnabled
}
return hasExistingExpirationDate || isDefaultInternalExpireDateEnabled
return this.isValidShareAttribute(this.share.expireDate)
},
set(enabled) {
this.share.expireDate = enabled
Expand Down Expand Up @@ -430,14 +418,14 @@ export default {
return this.fileInfo.type === 'dir'
},
maxExpirationDateEnforced() {
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
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
Expand Down Expand Up @@ -715,10 +703,19 @@ export default {
this.share.newPassword = await GeneratePassword()
this.advancedSectionAccordionExpanded = true
}
if (this.hasExpirationDate) {
this.share.expireDate = this.defaultExpiryDate
/* Set default expiration dates if configured */
if (this.isPublicShare && this.config.isDefaultExpireDateEnabled) {
this.share.expireDate = this.config.defaultExpirationDate.toDateString()
} else if (this.isRemoteShare && this.config.isDefaultRemoteExpireDateEnabled) {
this.share.expireDate = this.config.defaultRemoteExpirationDateString.toDateString()
} else if (this.config.isDefaultInternalExpireDateEnabled) {
this.share.expireDate = this.config.defaultInternalExpirationDate.toDateString()
}
if (this.isValidShareAttribute(this.share.expireDate)) {
this.advancedSectionAccordionExpanded = true
}
return
}
Expand Down
3 changes: 3 additions & 0 deletions dist/4511-4511.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/4511-4511.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions dist/9923-9923.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/9923-9923.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

0 comments on commit 6114364

Please sign in to comment.