Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] Improve share logic for enforced password & expiry date #41936

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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 ?
*
Expand Down
16 changes: 16 additions & 0 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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: {
Expand Down