Skip to content

Commit 05300c6

Browse files
committed
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>
1 parent 6f1bd07 commit 05300c6

7 files changed

Lines changed: 43 additions & 39 deletions

File tree

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@
9797
</NcActionText>
9898
<NcActionInput v-if="pendingExpirationDate"
9999
class="share-link-expire-date"
100-
:disabled="saving || isExpiryDateEnforced"
100+
:disabled="saving"
101101
:is-native-picker="true"
102102
:hide-label="true"
103103
:value="new Date(share.expireDate)"
104104
type="date"
105105
:min="dateTomorrow"
106-
:max="dateMaxEnforced"
106+
:max="maxExpirationDateEnforced"
107107
@input="onExpirationChange">
108108
<!-- let's not submit when picked, the user
109109
might want to still edit or copy the password -->
@@ -302,12 +302,6 @@ export default {
302302
}
303303
return null
304304
},
305-
dateMaxEnforced() {
306-
if (this.config.isDefaultExpireDateEnforced) {
307-
return new Date(new Date().setDate(new Date().getDate() + this.config.defaultExpireDate))
308-
}
309-
return null
310-
},
311305
/**
312306
* Is the current share password protected ?
313307
*

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export default {
132132
const shareType = this.share.shareType ?? this.share.type
133133
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
134134
},
135+
isRemoteShare() {
136+
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
137+
},
135138
isShareOwner() {
136139
return this.share && this.share.owner === getCurrentUser().uid
137140
},
@@ -152,6 +155,19 @@ export default {
152155
]
153156
return !bundledPermissions.includes(this.share.permissions)
154157
},
158+
maxExpirationDateEnforced() {
159+
if (this.isExpiryDateEnforced) {
160+
if (this.isPublicShare) {
161+
return this.config.defaultExpirationDate
162+
}
163+
if (this.isRemoteShare) {
164+
return this.config.defaultRemoteExpirationDateString
165+
}
166+
// If it get's here then it must be an internal share
167+
return this.config.defaultInternalExpirationDate
168+
}
169+
return null
170+
},
155171
},
156172

157173
methods: {

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
</div>
7171
</div>
7272
<div class="sharingTabDetailsView__advanced-control">
73-
<NcButton type="tertiary"
73+
<NcButton id="advancedSectionAccordionAdvancedControl"
74+
type="tertiary"
7475
alignment="end-reverse"
7576
@click="advancedSectionAccordionExpanded = !advancedSectionAccordionExpanded">
7677
{{ t('files_sharing', 'Advanced settings') }}
@@ -79,7 +80,11 @@
7980
</template>
8081
</NcButton>
8182
</div>
82-
<div v-if="advancedSectionAccordionExpanded" class="sharingTabDetailsView__advanced">
83+
<div v-if="advancedSectionAccordionExpanded"
84+
id="advancedSectionAccordionAdvanced"
85+
class="sharingTabDetailsView__advanced"
86+
aria-labelledby="advancedSectionAccordionAdvancedControl"
87+
role="region">
8388
<section>
8489
<NcInputField v-if="isPublicShare"
8590
:value.sync="share.label"
@@ -406,19 +411,6 @@ export default {
406411
isFolder() {
407412
return this.fileInfo.type === 'dir'
408413
},
409-
maxExpirationDateEnforced() {
410-
if (this.isExpiryDateEnforced) {
411-
if (this.isPublicShare) {
412-
return this.config.defaultExpirationDate
413-
}
414-
if (this.isRemoteShare) {
415-
return this.config.defaultRemoteExpirationDateString
416-
}
417-
// If it get's here then it must be an internal share
418-
return this.config.defaultInternalExpirationDate
419-
}
420-
return null
421-
},
422414
/**
423415
* @return {boolean}
424416
*/
@@ -457,9 +449,6 @@ export default {
457449
isGroupShare() {
458450
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_GROUP
459451
},
460-
isRemoteShare() {
461-
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
462-
},
463452
isNewShare() {
464453
return this.share.id === null || this.share.id === undefined
465454
},
@@ -631,6 +620,9 @@ export default {
631620
: translatedPermissions[permission].toLocaleLowerCase(getLanguage()))
632621
.join(', ')
633622
},
623+
advancedControlExpandedValue() {
624+
return this.advancedSectionAccordionExpanded ? 'true' : 'false'
625+
},
634626
},
635627
watch: {
636628
setCustomPermissions(isChecked) {
@@ -707,6 +699,12 @@ export default {
707699
return
708700
}
709701
702+
// If there is an enforced expiry date, then existing shares created before enforcement
703+
// have no expiry date, hence we set it here.
704+
if (!this.isValidShareAttribute(this.share.expireDate) && this.isExpiryDateEnforced) {
705+
this.hasExpirationDate = true
706+
}
707+
710708
if (
711709
this.isValidShareAttribute(this.share.password)
712710
|| this.isValidShareAttribute(this.share.expireDate)
@@ -762,16 +760,12 @@ export default {
762760
if (!this.writeNoteToRecipientIsChecked) {
763761
this.share.note = ''
764762
}
765-
766763
if (this.isPasswordProtected) {
767-
if (this.isValidShareAttribute(this.share.newPassword)) {
764+
if (this.hasUnsavedPassword && this.isValidShareAttribute(this.share.newPassword)) {
768765
this.share.password = this.share.newPassword
769766
this.$delete(this.share, 'newPassword')
770-
} else {
771-
if (this.isPasswordEnforced) {
772-
this.passwordError = true
773-
return
774-
}
767+
} else if (this.isPasswordEnforced && !this.isValidShareAttribute(this.share.password)) {
768+
this.passwordError = true
775769
}
776770
} else {
777771
this.share.password = ''

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-files_sharing_tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)