Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(files_sharing): Apply default password setting in SharingDetailsTab
Signed-off-by: nfebe <[email protected]>
  • Loading branch information
nfebe authored and AndyScherzinger committed Apr 15, 2025
commit 3c2b0dc063b0732baf6051a4d26c2e7d476a316c
18 changes: 0 additions & 18 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { Type as ShareTypes } from '@nextcloud/sharing'
import Vue from 'vue'
import VueQrcode from '@chenfengyuan/vue-qrcode'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
Expand Down Expand Up @@ -382,23 +381,6 @@ export default {
}
return null
},
/**
* Is the current share password protected ?
*
* @return {boolean}
*/
isPasswordProtected: {
get() {
return this.config.enforcePasswordForPublicLink
|| !!this.share.password
},
async set(enabled) {
// TODO: directly save after generation to make sure the share is always protected
Vue.set(this.share, 'password', enabled ? await GeneratePassword() : '')
Vue.set(this.share, 'newPassword', this.share.password)
},
},

passwordExpirationTime() {
if (this.share.passwordExpirationTime === null) {
return null
Expand Down
21 changes: 21 additions & 0 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { fetchNode } from '../services/WebdavClient.ts'
import PQueue from 'p-queue'
import debounce from 'debounce'

import GeneratePassword from '../utils/GeneratePassword.js'
import Share from '../models/Share.js'
import SharesRequests from './ShareRequests.js'
import ShareTypes from './ShareTypes.js'
Expand Down Expand Up @@ -177,6 +178,26 @@ export default {
}
return null
},
/**
* Is the current share password protected ?
*
* @return {boolean}
*/
isPasswordProtected: {
get() {
return this.config.enforcePasswordForPublicLink
|| !!this.share.password
},
async set(enabled) {
if (enabled) {
this.share.password = await GeneratePassword()
this.$set(this.share, 'newPassword', this.share.password)
} else {
this.share.password = ''
this.$delete(this.share, 'newPassword')
}
},
},
},

methods: {
Expand Down
23 changes: 2 additions & 21 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -456,26 +456,6 @@ export default {
: ''
},
},
/**
* Is the current share password protected ?
*
* @return {boolean}
*/
isPasswordProtected: {
get() {
return this.config.enforcePasswordForPublicLink
|| !!this.share.password
},
async set(enabled) {
if (enabled) {
this.share.password = await GeneratePassword()
this.$set(this.share, 'newPassword', this.share.password)
} else {
this.share.password = ''
this.$delete(this.share, 'newPassword')
}
},
},
/**
* Is the current share a folder ?
*
Expand Down Expand Up @@ -776,8 +756,9 @@ export default {
async initializeAttributes() {

if (this.isNewShare) {
if (this.isPasswordEnforced && this.isPublicShare) {
if ((this.config.enableLinkPasswordByDefault || this.isPasswordEnforced) && this.isPublicShare) {
this.$set(this.share, 'newPassword', await GeneratePassword())
this.$set(this.share, 'password', this.share.newPassword)
this.advancedSectionAccordionExpanded = true
}
/* Set default expiration dates if configured */
Expand Down