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

Improve share logic for enforced password & expiry date #41885

Merged
merged 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 @@ -95,13 +95,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 @@ -300,12 +300,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
45 changes: 17 additions & 28 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
</div>
</div>
<div class="sharingTabDetailsView__advanced-control">
<NcButton type="tertiary"
id="advancedSectionAccordionAdvancedControl"
<NcButton id="advancedSectionAccordionAdvancedControl"
type="tertiary"
alignment="end-reverse"
aria-controls="advancedSectionAccordionAdvanced"
:aria-expanded="advancedControlExpandedValue"
Expand All @@ -91,8 +91,11 @@
</template>
</NcButton>
</div>
<div v-if="advancedSectionAccordionExpanded" id="advancedSectionAccordionAdvanced" class="sharingTabDetailsView__advanced"
aria-labelledby="advancedSectionAccordionAdvancedControl" role="region">
<div v-if="advancedSectionAccordionExpanded"
id="advancedSectionAccordionAdvanced"
class="sharingTabDetailsView__advanced"
aria-labelledby="advancedSectionAccordionAdvancedControl"
role="region">
<section>
<NcInputField v-if="isPublicShare"
:value.sync="share.label"
Expand Down Expand Up @@ -427,19 +430,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}
*/
Expand Down Expand Up @@ -478,9 +468,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
},
Expand Down Expand Up @@ -654,7 +641,7 @@ export default {
},
advancedControlExpandedValue() {
return this.advancedSectionAccordionExpanded ? 'true' : 'false'
}
},
},
watch: {
setCustomPermissions(isChecked) {
Expand Down Expand Up @@ -731,6 +718,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)
Expand Down Expand Up @@ -786,16 +779,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 = ''
Expand Down
6 changes: 3 additions & 3 deletions dist/8673-8673.js → dist/3502-3502.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/8673-8673.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.

Loading