Skip to content

Commit

Permalink
fix(files_sharing): Password field must not be required if already set
Browse files Browse the repository at this point in the history
If there is already a password, there is no need to require the password

in the setting ('newPassword'). It is only required for new shares.

Signed-off-by: Ferdinand Thiessen <[email protected]>

[skip ci]
  • Loading branch information
susnux authored and backportbot[bot] committed Oct 30, 2024
1 parent f0bc87c commit 16488db
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
autocomplete="new-password"
:value="hasUnsavedPassword ? share.newPassword : ''"
:error="passwordError"
:helper-text="errorPasswordLabel"
:required="isPasswordEnforced"
:helper-text="errorPasswordLabel || passwordHint"
:required="isPasswordEnforced && isNewShare"
:label="t('files_sharing', 'Password')"
@update:value="onPasswordChange" />

Expand Down Expand Up @@ -707,6 +707,13 @@ export default {
return undefined
},
passwordHint() {
if (this.isNewShare || this.hasUnsavedPassword) {
return undefined
}
return t('files_sharing', 'Replace current password')
},
/**
* Additional actions for the menu
*
Expand Down Expand Up @@ -867,7 +874,7 @@ export default {
if (this.hasUnsavedPassword && this.isValidShareAttribute(this.share.newPassword)) {
this.share.password = this.share.newPassword
this.$delete(this.share, 'newPassword')
} else if (this.isPasswordEnforced && !this.isValidShareAttribute(this.share.password)) {
} else if (this.isPasswordEnforced && this.isNewShare && !this.isValidShareAttribute(this.share.password)) {
this.passwordError = true
}
} else {
Expand Down Expand Up @@ -961,6 +968,11 @@ export default {
* @param {string} password the changed password
*/
onPasswordChange(password) {
if (password === '') {
this.$delete(this.share, 'newPassword')
this.passwordError = this.isNewShare && this.isPasswordEnforced
return
}
this.passwordError = !this.isValidShareAttribute(password)
this.$set(this.share, 'newPassword', password)
},
Expand Down

0 comments on commit 16488db

Please sign in to comment.