Skip to content

Commit 7c5009f

Browse files
committed
fix: Fix clearing the new password
"newPassword" is internally delegated by the share object to "_share.newPassword" through getter and setter properties. Therefore deleting "newPassword" has no effect, as there is no such attribute, and it should be set to undefined instead. Now that "newPassword" is correctly cleared "Set password" is no longer checked if the share of a password is removed, the share is updated, and the share is customized again (without reloading the page in the meantime). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent 68f67d5 commit 7c5009f

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export default {
327327
if (propertyNames.includes('password')) {
328328
// reset password state after sync
329329
this.share.password = this.share.newPassword || undefined
330-
this.$delete(this.share, 'newPassword')
330+
this.$set(this.share, 'newPassword', undefined)
331331

332332
// updates password expiration time after sync
333333
this.share.passwordExpirationTime = updatedShare.password_expiration_time
@@ -398,7 +398,7 @@ export default {
398398
if (this.share.newPassword === this.share.password) {
399399
this.share.password = ''
400400
}
401-
this.$delete(this.share, 'newPassword')
401+
this.$set(this.share, 'newPassword', undefined)
402402
}
403403

404404
// re-open menu if closed

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ export default {
12581258
*/
12591259
onPasswordChange(password) {
12601260
if (password === '') {
1261-
this.$delete(this.share, 'newPassword')
1261+
this.$set(this.share, 'newPassword', undefined)
12621262
this.passwordError = this.isNewShare && this.isPasswordEnforced
12631263
return
12641264
}

tests/playwright/e2e/files_sharing/public-share/share-editor.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,27 @@ test.describe('files_sharing: Link share editor', () => {
103103
await expect(sharingTab.checkbox('Note to recipient')).not.toBeChecked()
104104
await expect(sharingTab.checkbox('Custom permissions')).not.toBeChecked()
105105
})
106+
107+
test('the password is unchecked after clearing and saving it', async ({ filesListPage, sharingTab }) => {
108+
await openSharingPanel(filesListPage, sharingTab, 'test')
109+
110+
await sharingTab.openLinkShareDetails()
111+
await sharingTab.openAdvancedSettings()
112+
await expect(sharingTab.checkbox('Set password')).not.toBeChecked()
113+
await sharingTab.setCheckbox('Set password', true)
114+
// A password is automatically generated and added to the input
115+
await sharingTab.save()
116+
117+
await sharingTab.openLinkShareDetails()
118+
await sharingTab.openAdvancedSettings()
119+
await expect(sharingTab.checkbox('Set password')).toBeChecked()
120+
await sharingTab.setCheckbox('Set password', false)
121+
await sharingTab.save()
122+
123+
await sharingTab.openLinkShareDetails()
124+
await sharingTab.openAdvancedSettings()
125+
await expect(sharingTab.checkbox('Set password')).not.toBeChecked()
126+
})
106127
})
107128

108129
test.describe('files_sharing: Email share editor', () => {

0 commit comments

Comments
 (0)