Skip to content

Commit f984570

Browse files
committed
fix(files_sharing): Password field must not be required if already set
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 <opensource@fthiessen.de>
1 parent dac15d1 commit f984570

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116
autocomplete="new-password"
117117
:value="hasUnsavedPassword ? share.newPassword : ''"
118118
:error="passwordError"
119-
:helper-text="errorPasswordLabel"
120-
:required="isPasswordEnforced"
119+
:helper-text="errorPasswordLabel || passwordHint"
120+
:required="isPasswordEnforced && isNewShare"
121121
:label="t('files_sharing', 'Password')"
122122
@update:value="onPasswordChange" />
123123

@@ -723,6 +723,13 @@ export default {
723723
return undefined
724724
},
725725
726+
passwordHint() {
727+
if (this.isNewShare || this.hasUnsavedPassword) {
728+
return undefined
729+
}
730+
return t('files_sharing', 'Replace current password')
731+
},
732+
726733
/**
727734
* Additional actions for the menu
728735
*
@@ -887,7 +894,7 @@ export default {
887894
if (this.hasUnsavedPassword && this.isValidShareAttribute(this.share.newPassword)) {
888895
this.share.password = this.share.newPassword
889896
this.$delete(this.share, 'newPassword')
890-
} else if (this.isPasswordEnforced && !this.isValidShareAttribute(this.share.password)) {
897+
} else if (this.isPasswordEnforced && this.isNewShare && !this.isValidShareAttribute(this.share.password)) {
891898
this.passwordError = true
892899
}
893900
} else {
@@ -981,6 +988,11 @@ export default {
981988
* @param {string} password the changed password
982989
*/
983990
onPasswordChange(password) {
991+
if (password === '') {
992+
this.$delete(this.share, 'newPassword')
993+
this.passwordError = this.isNewShare && this.isPasswordEnforced
994+
return
995+
}
984996
this.passwordError = !this.isValidShareAttribute(password)
985997
this.$set(this.share, 'newPassword', password)
986998
},

0 commit comments

Comments
 (0)