Skip to content

Commit 4cfb4b4

Browse files
authored
Merge pull request #52208 from nextcloud/backport/52121/stable31
[stable31] fix(files_sharing): Apply default password setting in SharingDetailsTab
2 parents 1044a44 + 2902161 commit 4cfb4b4

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
@@ -222,7 +222,6 @@ import { showError, showSuccess } from '@nextcloud/dialogs'
222222
import { ShareType } from '@nextcloud/sharing'
223223
import VueQrcode from '@chenfengyuan/vue-qrcode'
224224
import moment from '@nextcloud/moment'
225-
import Vue from 'vue'
226225
227226
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
228227
import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
@@ -383,23 +382,6 @@ export default {
383382
}
384383
return null
385384
},
386-
/**
387-
* Is the current share password protected ?
388-
*
389-
* @return {boolean}
390-
*/
391-
isPasswordProtected: {
392-
get() {
393-
return this.config.enforcePasswordForPublicLink
394-
|| !!this.share.password
395-
},
396-
async set(enabled) {
397-
// TODO: directly save after generation to make sure the share is always protected
398-
Vue.set(this.share, 'password', enabled ? await GeneratePassword(true) : '')
399-
Vue.set(this.share, 'newPassword', this.share.password)
400-
},
401-
},
402-
403385
passwordExpirationTime() {
404386
if (this.share.passwordExpirationTime === null) {
405387
return null

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { emit } from '@nextcloud/event-bus'
1111
import PQueue from 'p-queue'
1212
import debounce from 'debounce'
1313

14+
import GeneratePassword from '../utils/GeneratePassword.ts'
1415
import Share from '../models/Share.ts'
1516
import SharesRequests from './ShareRequests.js'
1617
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
@@ -496,26 +496,6 @@ export default {
496496
: ''
497497
},
498498
},
499-
/**
500-
* Is the current share password protected ?
501-
*
502-
* @return {boolean}
503-
*/
504-
isPasswordProtected: {
505-
get() {
506-
return this.config.enforcePasswordForPublicLink
507-
|| !!this.share.password
508-
},
509-
async set(enabled) {
510-
if (enabled) {
511-
this.share.password = await GeneratePassword(true)
512-
this.$set(this.share, 'newPassword', this.share.password)
513-
} else {
514-
this.share.password = ''
515-
this.$delete(this.share, 'newPassword')
516-
}
517-
},
518-
},
519499
/**
520500
* Is the current share a folder ?
521501
*
@@ -873,8 +853,9 @@ export default {
873853
async initializeAttributes() {
874854
875855
if (this.isNewShare) {
876-
if (this.isPasswordEnforced && this.isPublicShare) {
856+
if ((this.config.enableLinkPasswordByDefault || this.isPasswordEnforced) && this.isPublicShare) {
877857
this.$set(this.share, 'newPassword', await GeneratePassword(true))
858+
this.$set(this.share, 'password', this.share.newPassword)
878859
this.advancedSectionAccordionExpanded = true
879860
}
880861
/* Set default expiration dates if configured */
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/7694-7694.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/7694-7694.js.map.license

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

dist/8299-8299.js.map

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

dist/8299-8299.js.map.license

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

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)