Merge pull request #55081 from nextcloud/backport/55073/master

fix(files_sharing): use `newPassword` always for the unsaved password
pull/45030/head
Maksim Sukharev 2025-09-13 16:00:18 +07:00 committed by GitHub
commit 7ff123b427
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 32 additions and 22 deletions

@ -517,7 +517,7 @@ export default {
return true
}
// Check if either password or expiration date is missing and enforced
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.password
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.newPassword
const isExpireDateMissing = this.config.isDefaultExpireDateEnforced && !this.share.expireDate
return isPasswordMissing || isExpireDateMissing
@ -639,15 +639,12 @@ export default {
logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
// ELSE, show the pending popovermenu
const share = new Share(shareDefaults)
// if password default or enforced, pre-fill with random one
if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink) {
shareDefaults.password = await GeneratePassword(true)
this.$set(share, 'newPassword', await GeneratePassword(true))
}
// create share & close menu
const share = new Share(shareDefaults)
share.newPassword = share.password
const component = await new Promise(resolve => {
this.$emit('add:share', share, resolve)
})
@ -711,7 +708,7 @@ export default {
const options = {
path,
shareType: ShareType.Link,
password: share.password,
password: share.newPassword,
expireDate: share.expireDate ?? '',
attributes: JSON.stringify(this.fileInfo.shareAttributes),
// we do not allow setting the publicUpload
@ -815,10 +812,8 @@ export default {
* cannot ensure data is up-to-date
*/
onPasswordDisable() {
this.share.password = ''
// reset password state after sync
this.$delete(this.share, 'newPassword')
this.$set(this.share, 'newPassword', '')
// only update if valid share.
if (this.share.id) {

@ -55,6 +55,9 @@ export default {
saving: false,
open: false,
/** @type {boolean | undefined} */
passwordProtectedState: undefined,
// concurrency management queue
// we want one queue per share
updateQueue: new PQueue({ concurrency: 1 }),
@ -164,15 +167,22 @@ export default {
*/
isPasswordProtected: {
get() {
return this.config.enforcePasswordForPublicLink
|| this.share.password !== undefined
|| this.share.newPassword !== undefined
if (this.config.enforcePasswordForPublicLink) {
return true
}
if (this.passwordProtectedState !== undefined) {
return this.passwordProtectedState
}
return this.share.newPassword !== undefined
|| this.share.password !== undefined
},
async set(enabled) {
if (enabled) {
this.passwordProtectedState = true
this.$set(this.share, 'newPassword', await GeneratePassword(true))
} else {
this.share.password = ''
this.passwordProtectedState = false
this.$delete(this.share, 'newPassword')
}
},
@ -208,6 +218,11 @@ export default {
return false
}
}
if (share.newPassword) {
if (typeof share.newPassword !== 'string') {
return false
}
}
if (share.expirationDate) {
const date = share.expirationDate
if (!date.isValid()) {
@ -394,7 +409,7 @@ export default {
* @param {string} message the error message
*/
onSyncError(property, message) {
if (property === 'password' && this.share.newPassword) {
if (property === 'password' && this.share.newPassword !== undefined) {
if (this.share.newPassword === this.share.password) {
this.share.password = ''
}

2
dist/4290-4290.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
4290-4290.js.license

2
dist/5056-5056.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +0,0 @@
5056-5056.js.license

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long