Merge pull request #40500 from nextcloud/improve-expire-date-enforcement

Consider share type for enforced share expiry dates
This commit is contained in:
Arthur Schiwon 2023-09-21 09:44:02 +02:00 committed by GitHub
commit d6445254ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 35 deletions

View file

@ -97,7 +97,7 @@
</NcActionText>
<NcActionInput v-if="pendingExpirationDate"
class="share-link-expire-date"
:disabled="saving"
:disabled="saving || isExpiryDateEnforced"
:is-native-picker="true"
:hide-label="true"
:value="new Date(share.expireDate)"
@ -302,34 +302,12 @@ export default {
}
return null
},
/**
* Does the current share have an expiration date
*
* @return {boolean}
*/
hasExpirationDate: {
get() {
return this.config.isDefaultExpireDateEnforced
|| !!this.share.expireDate
},
set(enabled) {
const defaultExpirationDate = this.config.defaultExpirationDate
|| new Date(new Date().setDate(new Date().getDate() + 1))
this.share.expireDate = enabled
? this.formatDateToString(defaultExpirationDate)
: ''
console.debug('Expiration date status', enabled, this.share.expireDate)
},
},
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 ?
*

View file

@ -135,6 +135,15 @@ export default {
isShareOwner() {
return this.share && this.share.owner === getCurrentUser().uid
},
isExpiryDateEnforced() {
if (this.isPublicShare) {
return this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced
}
return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
},
hasCustomPermissions() {
const bundledPermissions = [
BUNDLED_PERMISSIONS.ALL,

View file

@ -368,7 +368,13 @@ export default {
*/
hasExpirationDate: {
get() {
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced
if (this.isPublicShare) {
return !!this.share.expireDate || this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
}
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
},
set(enabled) {
this.share.expireDate = enabled
@ -401,7 +407,7 @@ export default {
return this.fileInfo.type === 'dir'
},
dateMaxEnforced() {
if (!this.isRemote && this.config.isDefaultInternalExpireDateEnforced) {
if (!this.isRemoteShare && this.config.isDefaultInternalExpireDateEnforced) {
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultInternalExpireDate))
} else if (this.config.isDefaultRemoteExpireDateEnforced) {
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultRemoteExpireDate))
@ -430,9 +436,6 @@ export default {
isPasswordEnforced() {
return this.isPublicShare && this.config.enforcePasswordForPublicLink
},
isExpiryDateEnforced() {
return this.config.isDefaultInternalExpireDateEnforced
},
defaultExpiryDate() {
if ((this.isGroupShare || this.isUserShare) && this.config.isDefaultInternalExpireDateEnabled) {
return new Date(this.config.defaultInternalExpirationDate)

File diff suppressed because one or more lines are too long

1
dist/188-188.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long