Skip to content

Commit

Permalink
fix: Do not ask for guest name on read only pdfs
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Aug 7, 2024
1 parent 03a79b8 commit e645815
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/helpers/guestName.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ const setGuestNameCookie = (username) => {
}
}

const shouldAskForGuestName = () => {
const shouldAskForGuestName = (mimetype, canWrite) => {
const noLoggedInUser = !getLoggedInUser()
const noGuestCookie = !cookieAlreadySet('guestUser')
const noCurrentUser = !getCurrentUser() || getCurrentUser()?.uid === ''
const isReadOnlyPDF = mimetype === 'application/pdf' && !canWrite

return noLoggedInUser && noGuestCookie && noCurrentUser
return noLoggedInUser && noGuestCookie && noCurrentUser && !isReadOnlyPDF
}

export {
Expand Down
10 changes: 9 additions & 1 deletion src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ export default {
type: String,
default: null,
},
mime: {
type: String,
default: null,
},
permissions: {
type: String,
default: '',
},
isEmbedded: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -271,7 +279,7 @@ export default {
}
this.postMessage.registerPostMessageHandler(this.postMessageHandler)
if (shouldAskForGuestName()) {
if (shouldAskForGuestName(this.mime, this.permissions?.includes('W'))) {
const { default: GuestNamePicker } = await import(
/* webpackChunkName: 'GuestNamePicker' */
'../components/GuestNamePicker.vue')
Expand Down

0 comments on commit e645815

Please sign in to comment.