mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 04:42:56 +08:00
fix(server): don't set the wrong context on logger (#10088)

This commit is contained in:
@@ -280,11 +280,14 @@ export class PermissionService {
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.logger.log("User's WorkspaceRole is lower than required", {
|
const info = {
|
||||||
workspaceId: ws,
|
workspaceId: ws,
|
||||||
userId: user,
|
userId: user,
|
||||||
requiredRole: WorkspaceRole[permission],
|
requiredRole: WorkspaceRole[permission],
|
||||||
});
|
};
|
||||||
|
this.logger.log(
|
||||||
|
`User's WorkspaceRole is lower than required (${JSON.stringify(info)})`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +630,7 @@ export class PermissionService {
|
|||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.logger.log("User's role is lower than required", {
|
const info = {
|
||||||
workspaceId: ws,
|
workspaceId: ws,
|
||||||
docId: doc,
|
docId: doc,
|
||||||
userId: user,
|
userId: user,
|
||||||
@@ -640,7 +643,10 @@ export class PermissionService {
|
|||||||
: undefined,
|
: undefined,
|
||||||
requiredRole: DocRole[role],
|
requiredRole: DocRole[role],
|
||||||
action,
|
action,
|
||||||
});
|
};
|
||||||
|
this.logger.log(
|
||||||
|
`User's role is lower than required (${JSON.stringify(info)})`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check whether user has workspace related permission
|
// check whether user has workspace related permission
|
||||||
|
|||||||
@@ -326,18 +326,18 @@ export class WorkspaceDocResolver {
|
|||||||
docId.guid
|
docId.guid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const info = {
|
||||||
|
workspaceId,
|
||||||
|
docId: rawDocId,
|
||||||
|
};
|
||||||
if (!isPublic) {
|
if (!isPublic) {
|
||||||
this.logger.log('Expect to revoke public doc, but it is not public', {
|
this.logger.log(
|
||||||
workspaceId,
|
`Expect to revoke public doc, but it is not public (${JSON.stringify(info)})`
|
||||||
docId: rawDocId,
|
);
|
||||||
});
|
|
||||||
throw new DocIsNotPublic('Doc is not public');
|
throw new DocIsNotPublic('Doc is not public');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log('Revoke public doc', {
|
this.logger.log(`Revoke public doc (${JSON.stringify(info)})`);
|
||||||
workspaceId,
|
|
||||||
docId: rawDocId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.permission.revokePublicPage(docId.workspace, docId.guid);
|
return this.permission.revokePublicPage(docId.workspace, docId.guid);
|
||||||
}
|
}
|
||||||
@@ -487,11 +487,12 @@ export class DocResolver {
|
|||||||
input.userIds,
|
input.userIds,
|
||||||
input.role
|
input.role
|
||||||
);
|
);
|
||||||
this.logger.log('Grant doc user roles', {
|
const info = {
|
||||||
...pairs,
|
...pairs,
|
||||||
userIds: input.userIds,
|
userIds: input.userIds,
|
||||||
role: input.role,
|
role: input.role,
|
||||||
});
|
};
|
||||||
|
this.logger.log(`Grant doc user roles (${JSON.stringify(info)})`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,10 +523,11 @@ export class DocResolver {
|
|||||||
user.id
|
user.id
|
||||||
);
|
);
|
||||||
await this.permission.revokePage(doc.workspace, doc.guid, input.userId);
|
await this.permission.revokePage(doc.workspace, doc.guid, input.userId);
|
||||||
this.logger.log('Revoke doc user roles', {
|
const info = {
|
||||||
...pairs,
|
...pairs,
|
||||||
userId: input.userId,
|
userId: input.userId,
|
||||||
});
|
};
|
||||||
|
this.logger.log(`Revoke doc user roles (${JSON.stringify(info)})`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,18 +566,15 @@ export class DocResolver {
|
|||||||
input.role
|
input.role
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const info = {
|
||||||
|
...pairs,
|
||||||
|
userId: input.userId,
|
||||||
|
role: input.role,
|
||||||
|
};
|
||||||
if (input.role === DocRole.Owner) {
|
if (input.role === DocRole.Owner) {
|
||||||
this.logger.log('Transfer doc owner', {
|
this.logger.log(`Transfer doc owner (${JSON.stringify(info)})`);
|
||||||
...pairs,
|
|
||||||
userId: input.userId,
|
|
||||||
role: input.role,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.logger.log('Update doc user role', {
|
this.logger.log(`Update doc user role (${JSON.stringify(info)})`);
|
||||||
...pairs,
|
|
||||||
userId: input.userId,
|
|
||||||
role: input.role,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -587,7 +586,9 @@ export class DocResolver {
|
|||||||
@Args('input') input: UpdateDocDefaultRoleInput
|
@Args('input') input: UpdateDocDefaultRoleInput
|
||||||
) {
|
) {
|
||||||
if (input.role === DocRole.Owner) {
|
if (input.role === DocRole.Owner) {
|
||||||
this.logger.log('Doc default role can not be owner', input);
|
this.logger.log(
|
||||||
|
`Doc default role can not be owner (${JSON.stringify(input)})`
|
||||||
|
);
|
||||||
throw new DocDefaultRoleCanNotBeOwner();
|
throw new DocDefaultRoleCanNotBeOwner();
|
||||||
}
|
}
|
||||||
const doc = new DocID(input.docId, input.workspaceId);
|
const doc = new DocID(input.docId, input.workspaceId);
|
||||||
@@ -615,11 +616,12 @@ export class DocResolver {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof DocAccessDenied) {
|
if (error instanceof DocAccessDenied) {
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
'User does not have permission to update page default role',
|
`User does not have permission to update page default role (${JSON.stringify(
|
||||||
{
|
{
|
||||||
...pairs,
|
...pairs,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
}
|
}
|
||||||
|
)})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class CreateCommand extends CommandRunner {
|
|||||||
|
|
||||||
this.logger.log(`Creating ${fileName}...`);
|
this.logger.log(`Creating ${fileName}...`);
|
||||||
writeFileSync(filePath, content);
|
writeFileSync(filePath, content);
|
||||||
this.logger.log('Migration file created at', filePath);
|
this.logger.log(`Migration file created at ${filePath}`);
|
||||||
this.logger.log('Done');
|
this.logger.log('Done');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user