Skip to content

Commit a28834b

Browse files
committed
fix(files_sharing): Only send password on change
The password param should never be sent if the intention is not remove it or update it. This commit adapts the frontend and backend to this rule to avoid weird bugs especially around updating new shares. Signed-off-by: nfebe <[email protected]>
1 parent 30b5f00 commit a28834b

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,10 +1344,13 @@ public function updateShare(
13441344
$share->setPermissions($permissions);
13451345
}
13461346

1347-
if ($password === '') {
1348-
$share->setPassword(null);
1349-
} elseif ($password !== null) {
1350-
$share->setPassword($password);
1347+
$passwordParamSent = $password !== null;
1348+
if ($passwordParamSent) {
1349+
if ($password === '') {
1350+
$share->setPassword(null);
1351+
} else {
1352+
$share->setPassword($password);
1353+
}
13511354
}
13521355

13531356
if ($label !== null) {

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ export default {
316316
// share api controller accepts
317317
for (const name of propertyNames) {
318318
if (name === 'password') {
319-
properties[name] = this.share.newPassword ?? this.share.password
319+
if (this.share.newPassword !== undefined) {
320+
properties[name] = this.share.newPassword
321+
}
320322
continue
321323
}
322324

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,11 @@ export default {
10541054
10551055
async saveShare() {
10561056
const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate']
1057-
const publicShareAttributes = ['label', 'password', 'hideDownload']
1057+
const publicShareAttributes = ['label', 'hideDownload']
1058+
// Only include password if it's being actively changed
1059+
if (this.hasUnsavedPassword) {
1060+
publicShareAttributes.push('password')
1061+
}
10581062
if (this.config.allowCustomTokens) {
10591063
publicShareAttributes.push('token')
10601064
}
@@ -1221,7 +1225,11 @@ export default {
12211225
* "sendPasswordByTalk".
12221226
*/
12231227
onPasswordProtectedByTalkChange() {
1224-
this.queueUpdate('sendPasswordByTalk', 'password')
1228+
if (this.isEmailShareType || this.hasUnsavedPassword) {
1229+
this.queueUpdate('sendPasswordByTalk', 'password')
1230+
} else {
1231+
this.queueUpdate('sendPasswordByTalk')
1232+
}
12251233
},
12261234
12271235
isValidShareAttribute(value) {

0 commit comments

Comments
 (0)