]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove `newPassword` from share model, if disabled
authorfenn-cs <fenn25.fn@gmail.com>
Wed, 6 Dec 2023 21:05:57 +0000 (22:05 +0100)
committerfenn-cs <fenn25.fn@gmail.com>
Wed, 6 Dec 2023 21:11:27 +0000 (22:11 +0100)
It's important to delete the `newPassword` prop from the share
 model, if the user unchecks the isPasswordProtected checkbox.

This clearer and allows for the unchecking to actually work as
`this.$set()` fails with the falsy value `''`.

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
apps/files_sharing/src/views/SharingDetailsTab.vue

index a4a312fcc0e3db8e944eb582b7b5aa7931fbeef3..d882aac9b87c035eee849f62b310c514549df686 100644 (file)
@@ -417,9 +417,13 @@ export default {
                                        || !!this.share.password
                        },
                        async set(enabled) {
-                               // TODO: directly save after generation to make sure the share is always protected
-                               this.share.password = enabled ? await GeneratePassword() : ''
-                               this.$set(this.share, 'newPassword', this.share.password)
+                               if (enabled) {
+                                       this.share.password = await GeneratePassword()
+                                       this.$set(this.share, 'newPassword', this.share.password)
+                               } else {
+                                       this.share.password = ''
+                                       this.$delete(this.share, 'newPassword')
+                               }
                        },
                },
                /**