Skip to content

Commit 2bab1e5

Browse files
authored
Merge pull request #52207 from nextcloud/backport/52121/stable30
[stable30] fix(files_sharing): Apply default password setting in SharingDetailsTab
2 parents 24be03e + 636b694 commit 2bab1e5

11 files changed

Lines changed: 30 additions & 46 deletions

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ import { emit } from '@nextcloud/event-bus'
219219
import { generateUrl } from '@nextcloud/router'
220220
import { showError, showSuccess } from '@nextcloud/dialogs'
221221
import { ShareType } from '@nextcloud/sharing'
222-
import Vue from 'vue'
223222
import VueQrcode from '@chenfengyuan/vue-qrcode'
224223
225224
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
@@ -375,23 +374,6 @@ export default {
375374
}
376375
return null
377376
},
378-
/**
379-
* Is the current share password protected ?
380-
*
381-
* @return {boolean}
382-
*/
383-
isPasswordProtected: {
384-
get() {
385-
return this.config.enforcePasswordForPublicLink
386-
|| !!this.share.password
387-
},
388-
async set(enabled) {
389-
// TODO: directly save after generation to make sure the share is always protected
390-
Vue.set(this.share, 'password', enabled ? await GeneratePassword(true) : '')
391-
Vue.set(this.share, 'newPassword', this.share.password)
392-
},
393-
},
394-
395377
passwordExpirationTime() {
396378
if (this.share.passwordExpirationTime === null) {
397379
return null

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { fetchNode } from '../services/WebdavClient.ts'
1212
import PQueue from 'p-queue'
1313
import debounce from 'debounce'
1414

15+
import GeneratePassword from '../utils/GeneratePassword.ts'
1516
import Share from '../models/Share.ts'
1617
import SharesRequests from './ShareRequests.js'
1718
import Config from '../services/ConfigService.ts'
@@ -156,6 +157,26 @@ export default {
156157
}
157158
return null
158159
},
160+
/**
161+
* Is the current share password protected ?
162+
*
163+
* @return {boolean}
164+
*/
165+
isPasswordProtected: {
166+
get() {
167+
return this.config.enforcePasswordForPublicLink
168+
|| !!this.share.password
169+
},
170+
async set(enabled) {
171+
if (enabled) {
172+
this.share.password = await GeneratePassword(true)
173+
this.$set(this.share, 'newPassword', this.share.password)
174+
} else {
175+
this.share.password = ''
176+
this.$delete(this.share, 'newPassword')
177+
}
178+
},
179+
},
159180
},
160181

161182
methods: {

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -461,26 +461,6 @@ export default {
461461
: ''
462462
},
463463
},
464-
/**
465-
* Is the current share password protected ?
466-
*
467-
* @return {boolean}
468-
*/
469-
isPasswordProtected: {
470-
get() {
471-
return this.config.enforcePasswordForPublicLink
472-
|| !!this.share.password
473-
},
474-
async set(enabled) {
475-
if (enabled) {
476-
this.share.password = await GeneratePassword(true)
477-
this.$set(this.share, 'newPassword', this.share.password)
478-
} else {
479-
this.share.password = ''
480-
this.$delete(this.share, 'newPassword')
481-
}
482-
},
483-
},
484464
/**
485465
* Is the current share a folder ?
486466
*
@@ -784,8 +764,9 @@ export default {
784764
async initializeAttributes() {
785765
786766
if (this.isNewShare) {
787-
if (this.isPasswordEnforced && this.isPublicShare) {
767+
if ((this.config.enableLinkPasswordByDefault || this.isPasswordEnforced) && this.isPublicShare) {
788768
this.$set(this.share, 'newPassword', await GeneratePassword(true))
769+
this.$set(this.share, 'password', this.share.newPassword)
789770
this.advancedSectionAccordionExpanded = true
790771
}
791772
/* Set default expiration dates if configured */

dist/7161-7161.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/7161-7161.js.map.license

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/8189-8189.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/8189-8189.js.map.license

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8189-8189.js.license

dist/files_sharing-files_sharing_tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)