Allow guest users edit documents created by them (#10695)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-03-27 13:39:38 +07:00
committed by GitHub
parent b42782db1f
commit 080682995b
2 changed files with 20 additions and 1 deletions
+12
View File
@@ -88,6 +88,18 @@ export function setCurrentEmployeeSpace (space: Ref<PersonSpace>): void {
currentEmployeeSpace = space
}
/**
* True when {@link Doc.createdBy} is one of the given account's social identities.
*
* @public
*/
export function isDocCreatedByAccount (doc: Doc, account: Account): boolean {
const creator = doc.createdBy
if (creator === undefined) return false
if (creator === account.primarySocialId) return true
return account.socialIds.includes(creator)
}
/**
* @public
*/
@@ -38,6 +38,7 @@
imageSizeToRatio,
KeyedAttribute
} from '@hcengineering/presentation'
import { isDocCreatedByAccount } from '@hcengineering/contact'
import { markupToJSON } from '@hcengineering/text'
import {
AnySvelteComponent,
@@ -131,7 +132,13 @@
let editorReady = false
$: loading = !synced
$: editable = !readonly && !contentError && synced && editorReady && hasAccountRole(account, AccountRole.User)
$: canEditAsGuestCreator = account.role === AccountRole.Guest && isDocCreatedByAccount(object, account)
$: editable =
!readonly &&
!contentError &&
synced &&
editorReady &&
(hasAccountRole(account, AccountRole.User) || canEditAsGuestCreator)
void provider.loaded.then(() => (synced = true))
void provider.loaded.then(() => dispatch('loaded'))