From f0de34a60bc62adb9df2695ba57bd599c1a63c64 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 13 Sep 2023 23:26:41 -0700 Subject: [PATCH] fix(server): everyone can share page in workspace (#4357) --- apps/server/src/modules/workspaces/resolver.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/server/src/modules/workspaces/resolver.ts b/apps/server/src/modules/workspaces/resolver.ts index e36ab8d85c..49f849bafa 100644 --- a/apps/server/src/modules/workspaces/resolver.ts +++ b/apps/server/src/modules/workspaces/resolver.ts @@ -30,7 +30,6 @@ import type { User, Workspace } from '@prisma/client'; import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs'; import { applyUpdate, Doc } from 'yjs'; -import { Config } from '../../config'; import { PrismaService } from '../../prisma'; import { StorageProvide } from '../../storage'; import { CloudThrottlerGuard, Throttle } from '../../throttler'; @@ -139,7 +138,6 @@ export class WorkspaceResolver { constructor( private readonly auth: AuthService, - private readonly config: Config, private readonly mailer: MailService, private readonly prisma: PrismaService, private readonly permissions: PermissionService, @@ -644,9 +642,16 @@ export class WorkspaceResolver { @Args('workspaceId') workspaceId: string, @Args('pageId') pageId: string ) { - await this.permissions.check(workspaceId, user.id, Permission.Admin); - - return this.permissions.grantPage(workspaceId, pageId); + const userWorkspace = await this.prisma.userWorkspacePermission.findFirst({ + where: { + userId: user.id, + workspaceId, + }, + }); + return ( + userWorkspace?.accepted && + (await this.permissions.grantPage(workspaceId, pageId)) + ); } @Mutation(() => Boolean)