Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 5 additions & 10 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export default {
return true
}
// Check if either password or expiration date is missing and enforced
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.password
const isPasswordMissing = this.config.enforcePasswordForPublicLink && !this.share.newPassword
const isExpireDateMissing = this.config.isDefaultExpireDateEnforced && !this.share.expireDate

return isPasswordMissing || isExpireDateMissing
Expand Down Expand Up @@ -631,15 +631,12 @@ export default {

logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')

// ELSE, show the pending popovermenu
const share = new Share(shareDefaults)
// if password default or enforced, pre-fill with random one
if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink) {
shareDefaults.password = await GeneratePassword(true)
this.$set(share, 'newPassword', await GeneratePassword(true))
}

// create share & close menu
const share = new Share(shareDefaults)
share.newPassword = share.password
const component = await new Promise(resolve => {
this.$emit('add:share', share, resolve)
})
Expand Down Expand Up @@ -703,7 +700,7 @@ export default {
const options = {
path,
shareType: ShareType.Link,
password: share.password,
password: share.newPassword,
expireDate: share.expireDate ?? '',
attributes: JSON.stringify(this.fileInfo.shareAttributes),
// we do not allow setting the publicUpload
Expand Down Expand Up @@ -810,10 +807,8 @@ export default {
* cannot ensure data is up-to-date
*/
onPasswordDisable() {
this.share.password = ''

// reset password state after sync
this.$delete(this.share, 'newPassword')
this.$set(this.share, 'newPassword', '')

// only update if valid share.
if (this.share.id) {
Expand Down
25 changes: 20 additions & 5 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export default {
saving: false,
open: false,

/** @type {boolean | undefined} */
passwordProtectedState: undefined,

// concurrency management queue
// we want one queue per share
updateQueue: new PQueue({ concurrency: 1 }),
Expand Down Expand Up @@ -164,15 +167,22 @@ export default {
*/
isPasswordProtected: {
get() {
return this.config.enforcePasswordForPublicLink
|| this.share.password !== undefined
|| this.share.newPassword !== undefined
if (this.config.enforcePasswordForPublicLink) {
return true
}
if (this.passwordProtectedState !== undefined) {
return this.passwordProtectedState
}
return this.share.newPassword !== undefined
|| this.share.password !== undefined

},
async set(enabled) {
if (enabled) {
this.passwordProtectedState = true
this.$set(this.share, 'newPassword', await GeneratePassword(true))
} else {
this.share.password = ''
this.passwordProtectedState = false
this.$delete(this.share, 'newPassword')
}
},
Expand Down Expand Up @@ -208,6 +218,11 @@ export default {
return false
}
}
if (share.newPassword) {
if (typeof share.newPassword !== 'string') {
return false
}
}
if (share.expirationDate) {
const date = share.expirationDate
if (!date.isValid()) {
Expand Down Expand Up @@ -394,7 +409,7 @@ export default {
* @param {string} message the error message
*/
onSyncError(property, message) {
if (property === 'password' && this.share.newPassword) {
if (property === 'password' && this.share.newPassword !== undefined) {
if (this.share.newPassword === this.share.password) {
this.share.password = ''
}
Expand Down
2 changes: 2 additions & 0 deletions dist/5768-5768.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/5768-5768.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/5768-5768.js.map.license
2 changes: 0 additions & 2 deletions dist/5783-5783.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/5783-5783.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/5783-5783.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

Loading