Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files_sharing): Password field must not be required if already set #48991

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -116,8 +116,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 @@ -723,6 +723,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 @@ -887,7 +894,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 @@ -981,6 +988,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
Loading