Skip to content

Commit

Permalink
Merge pull request #4030 from nextcloud/fix/failed-token-generation
Browse files Browse the repository at this point in the history
fix: failed token generation on public shares
  • Loading branch information
elzody committed Sep 17, 2024
2 parents d848797 + 90c5da5 commit fdfca61
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 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 @@ -36,6 +36,7 @@
"@nextcloud/paths": "^2.2.1",
"@nextcloud/router": "^3.0.1",
"@nextcloud/vue": "^8.18.0",
"@nextcloud/sharing": "^0.2.3",
"vue": "^2.7.16",
"vue-material-design-icons": "^5.3.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { getRootUrl, generateUrl } from '@nextcloud/router'
import { getSharingToken } from '@nextcloud/sharing/public'
import { languageToBCP47 } from './index.js'
import Config from './../services/config.tsx'

Expand Down Expand Up @@ -62,7 +63,7 @@ const getDocumentUrlForPublicFile = (fileName, fileId) => {
return generateUrl(
'apps/richdocuments/public?shareToken={shareToken}&fileName={fileName}&requesttoken={requesttoken}&fileId={fileId}',
{
shareToken: document.getElementById('sharingToken').value,
shareToken: getSharingToken(),
fileName,
fileId,
requesttoken: OC.requestToken,
Expand Down
3 changes: 2 additions & 1 deletion src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import axios from '@nextcloud/axios'
import { generateOcsUrl, generateFilePath } from '@nextcloud/router'
import { getSharingToken } from '@nextcloud/sharing/public'
import { getCurrentDirectory } from '../helpers/filesApp.js'

export const createEmptyFile = async (mimeType, fileName, templateId = null) => {
const shareToken = document.getElementById('sharingToken')?.value
const shareToken = getSharingToken()
const directoryPath = getCurrentDirectory()

const response = await axios.post(generateOcsUrl('apps/richdocuments/api/v1/file', 2), {
Expand Down
3 changes: 2 additions & 1 deletion src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import saveAs from '../mixins/saveAs.js'
import uiMention from '../mixins/uiMention.js'
import version from '../mixins/version.js'
import { getCurrentUser, getGuestNickname } from '@nextcloud/auth'
import { getSharingToken } from '@nextcloud/sharing/public'
import { shouldAskForGuestName } from '../helpers/guestName.js'
const FRAME_DOCUMENT = 'FRAME_DOCUMENT'
Expand Down Expand Up @@ -233,7 +234,7 @@ export default {
return document.getElementById('isPublic')?.value === '1'
},
shareToken() {
return document.getElementById('sharingToken')?.value
return getSharingToken()
},
showAdminStorageFailure() {
return getCurrentUser()?.isAdmin && this.errorType === 'websocketloadfailed'
Expand Down

0 comments on commit fdfca61

Please sign in to comment.