Skip to content

Commit 6ca8811

Browse files
susnuxAntreesy
authored andcommitted
fix(files_sharing): use newPassword always for the unsaved password
`newPassword` is the unsaved password, while `share.password` is the current saved password. Signed-off-by: Ferdinand Thiessen <[email protected]> [skip ci]
1 parent b958db0 commit 6ca8811

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export default {
517517
return true
518518
}
519519
// Check if either password or expiration date is missing and enforced
520-
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.password
520+
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.newPassword
521521
const isExpireDateMissing = this.config.isDefaultExpireDateEnforced && !this.share.expireDate
522522
523523
return isPasswordMissing || isExpireDateMissing
@@ -639,15 +639,12 @@ export default {
639639
640640
logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
641641
642-
// ELSE, show the pending popovermenu
642+
const share = new Share(shareDefaults)
643643
// if password default or enforced, pre-fill with random one
644644
if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink) {
645-
shareDefaults.password = await GeneratePassword(true)
645+
this.$set(share, 'newPassword', await GeneratePassword(true))
646646
}
647647
648-
// create share & close menu
649-
const share = new Share(shareDefaults)
650-
share.newPassword = share.password
651648
const component = await new Promise(resolve => {
652649
this.$emit('add:share', share, resolve)
653650
})
@@ -711,7 +708,7 @@ export default {
711708
const options = {
712709
path,
713710
shareType: ShareType.Link,
714-
password: share.password,
711+
password: share.newPassword,
715712
expireDate: share.expireDate ?? '',
716713
attributes: JSON.stringify(this.fileInfo.shareAttributes),
717714
// we do not allow setting the publicUpload
@@ -815,10 +812,8 @@ export default {
815812
* cannot ensure data is up-to-date
816813
*/
817814
onPasswordDisable() {
818-
this.share.password = ''
819-
820815
// reset password state after sync
821-
this.$delete(this.share, 'newPassword')
816+
this.$set(this.share, 'newPassword', '')
822817
823818
// only update if valid share.
824819
if (this.share.id) {

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export default {
5555
saving: false,
5656
open: false,
5757

58+
/** @type {boolean | undefined} */
59+
passwordProtectedState: undefined,
60+
5861
// concurrency management queue
5962
// we want one queue per share
6063
updateQueue: new PQueue({ concurrency: 1 }),
@@ -164,15 +167,22 @@ export default {
164167
*/
165168
isPasswordProtected: {
166169
get() {
167-
return this.config.enforcePasswordForPublicLink
168-
|| this.share.password !== undefined
169-
|| this.share.newPassword !== undefined
170+
if (this.config.enforcePasswordForPublicLink) {
171+
return true
172+
}
173+
if (this.passwordProtectedState !== undefined) {
174+
return this.passwordProtectedState
175+
}
176+
return this.share.newPassword !== undefined
177+
|| this.share.password !== undefined
178+
170179
},
171180
async set(enabled) {
172181
if (enabled) {
182+
this.passwordProtectedState = true
173183
this.$set(this.share, 'newPassword', await GeneratePassword(true))
174184
} else {
175-
this.share.password = ''
185+
this.passwordProtectedState = false
176186
this.$delete(this.share, 'newPassword')
177187
}
178188
},
@@ -208,6 +218,11 @@ export default {
208218
return false
209219
}
210220
}
221+
if (share.newPassword) {
222+
if (typeof share.newPassword !== 'string') {
223+
return false
224+
}
225+
}
211226
if (share.expirationDate) {
212227
const date = share.expirationDate
213228
if (!date.isValid()) {
@@ -394,7 +409,7 @@ export default {
394409
* @param {string} message the error message
395410
*/
396411
onSyncError(property, message) {
397-
if (property === 'password' && this.share.newPassword) {
412+
if (property === 'password' && this.share.newPassword !== undefined) {
398413
if (this.share.newPassword === this.share.password) {
399414
this.share.password = ''
400415
}

0 commit comments

Comments
 (0)