Skip to content

Commit 44156c8

Browse files
committed
fix(files_sharing): Apply default password setting in SharingDetailsTab
Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent f8391e6 commit 44156c8

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,23 +391,6 @@ export default {
391391
}
392392
return null
393393
},
394-
/**
395-
* Is the current share password protected ?
396-
*
397-
* @return {boolean}
398-
*/
399-
isPasswordProtected: {
400-
get() {
401-
return this.config.enforcePasswordForPublicLink
402-
|| !!this.share.password
403-
},
404-
async set(enabled) {
405-
// TODO: directly save after generation to make sure the share is always protected
406-
Vue.set(this.share, 'password', enabled ? await GeneratePassword(true) : '')
407-
Vue.set(this.share, 'newPassword', this.share.password)
408-
},
409-
},
410-
411394
passwordExpirationTime() {
412395
if (this.share.passwordExpirationTime === null) {
413396
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 */

0 commit comments

Comments
 (0)