mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 05:31:31 +03:00
fix(server): everyone can share page in workspace (#4357)
This commit is contained in:
parent
1016a47b51
commit
f0de34a60b
@ -30,7 +30,6 @@ import type { User, Workspace } from '@prisma/client';
|
|||||||
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
|
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
|
||||||
import { applyUpdate, Doc } from 'yjs';
|
import { applyUpdate, Doc } from 'yjs';
|
||||||
|
|
||||||
import { Config } from '../../config';
|
|
||||||
import { PrismaService } from '../../prisma';
|
import { PrismaService } from '../../prisma';
|
||||||
import { StorageProvide } from '../../storage';
|
import { StorageProvide } from '../../storage';
|
||||||
import { CloudThrottlerGuard, Throttle } from '../../throttler';
|
import { CloudThrottlerGuard, Throttle } from '../../throttler';
|
||||||
@ -139,7 +138,6 @@ export class WorkspaceResolver {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly auth: AuthService,
|
private readonly auth: AuthService,
|
||||||
private readonly config: Config,
|
|
||||||
private readonly mailer: MailService,
|
private readonly mailer: MailService,
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly permissions: PermissionService,
|
private readonly permissions: PermissionService,
|
||||||
@ -644,9 +642,16 @@ export class WorkspaceResolver {
|
|||||||
@Args('workspaceId') workspaceId: string,
|
@Args('workspaceId') workspaceId: string,
|
||||||
@Args('pageId') pageId: string
|
@Args('pageId') pageId: string
|
||||||
) {
|
) {
|
||||||
await this.permissions.check(workspaceId, user.id, Permission.Admin);
|
const userWorkspace = await this.prisma.userWorkspacePermission.findFirst({
|
||||||
|
where: {
|
||||||
return this.permissions.grantPage(workspaceId, pageId);
|
userId: user.id,
|
||||||
|
workspaceId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
userWorkspace?.accepted &&
|
||||||
|
(await this.permissions.grantPage(workspaceId, pageId))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
|
Loading…
Reference in New Issue
Block a user