File tree Expand file tree Collapse file tree 3 files changed +23
-38
lines changed
Expand file tree Collapse file tree 3 files changed +23
-38
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { emit } from '@nextcloud/event-bus'
1111import PQueue from 'p-queue'
1212import debounce from 'debounce'
1313
14+ import GeneratePassword from '../utils/GeneratePassword.ts'
1415import Share from '../models/Share.ts'
1516import SharesRequests from './ShareRequests.js'
1617import 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 : {
Original file line number Diff line number Diff 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 */
You can’t perform that action at this time.
0 commit comments