Optimize metadata queries (#7013)
In this PR: 1. Refactor guards to avoid duplicated queries: WorkspaceAuthGuard and UserAuthGuard only check for existence of workspace and user in the request without querying the database
This commit is contained in:
committed by
Charles Bochet
parent
cf8b1161cc
commit
523df5398a
@ -6,7 +6,7 @@ import {
|
||||
|
||||
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
|
||||
import { CreateAppTokenInput } from 'src/engine/core-modules/app-token/dtos/create-app-token.input';
|
||||
import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard';
|
||||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
||||
|
||||
export const appTokenAutoResolverOpts: AutoResolverOpts<
|
||||
any,
|
||||
@ -34,6 +34,6 @@ export const appTokenAutoResolverOpts: AutoResolverOpts<
|
||||
one: { disabled: true },
|
||||
},
|
||||
delete: { many: { disabled: true }, one: { disabled: true } },
|
||||
guards: [JwtAuthGuard],
|
||||
guards: [WorkspaceAuthGuard],
|
||||
},
|
||||
];
|
||||
|
||||
@ -13,7 +13,7 @@ export class BeforeCreateOneAppToken<T extends AppToken>
|
||||
instance: CreateOneInputType<T>,
|
||||
context: any,
|
||||
): Promise<CreateOneInputType<T>> {
|
||||
const userId = context?.req?.user?.user?.id;
|
||||
const userId = context?.req?.user?.id;
|
||||
|
||||
instance.input.userId = userId;
|
||||
// FIXME: These fields should be autogenerated, we need to run a migration for this
|
||||
|
||||
Reference in New Issue
Block a user