mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
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 <opensource@fthiessen.de>
This commit is contained in:
parent
b5b32078f6
commit
fdac770f56
2 changed files with 25 additions and 15 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 = ''
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue