mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Allow guest users edit documents created by them (#10695)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user