Skip to content

Commit

Permalink
fix(NcReferenceList): Use getSharingToken() from @nextcloud/sharing
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Jul 22, 2024
1 parent 99c97ba commit d39b28a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@nextcloud/l10n": "^3.0.1",
"@nextcloud/logger": "^3.0.1",
"@nextcloud/router": "^3.0.0",
"@nextcloud/sharing": "^0.2.2",
"@nextcloud/timezones": "^0.1.1",
"@nextcloud/vue-select": "^3.25.0",
"@vueuse/components": "^10.9.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/NcRichText/NcReferenceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import NcReferenceWidget from './NcReferenceWidget.vue'
import { URL_PATTERN } from './helpers.js'
import axios from '@nextcloud/axios'
import { getSharingToken } from '@nextcloud/sharing/public'
import { getCurrentUser } from '@nextcloud/auth'
import { generateOcsUrl } from '@nextcloud/router'
Expand Down Expand Up @@ -120,10 +121,9 @@ export default {
resolve() {
const match = (new RegExp(URL_PATTERN).exec(this.text.trim()))
const isPublic = getCurrentUser() === null
const sharingToken = document.getElementById('sharingToken')?.value || ''
if (this.limit === 1 && match) {
return isPublic
? axios.get(generateOcsUrl('references/resolvePublic') + `?reference=${encodeURIComponent(match[0])}&sharingToken=${sharingToken}`)
? axios.get(generateOcsUrl('references/resolvePublic') + `?reference=${encodeURIComponent(match[0])}&sharingToken=${getSharingToken()}`)
: axios.get(generateOcsUrl('references/resolve') + `?reference=${encodeURIComponent(match[0])}`)
}
Expand All @@ -132,7 +132,7 @@ export default {
text: this.text,
resolve: true,
limit: this.limit,
sharingToken,
sharingToken: getSharingToken(),
})
: axios.post(generateOcsUrl('references/extract'), {
text: this.text,
Expand Down

0 comments on commit d39b28a

Please sign in to comment.