Fix cache issue (#12527)
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
import { UseFilters, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
ExecutionContext,
|
||||
UseFilters,
|
||||
UseGuards,
|
||||
createParamDecorator,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
Args,
|
||||
Mutation,
|
||||
@ -53,12 +58,21 @@ import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-module
|
||||
import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
||||
import { RoleService } from 'src/engine/metadata-modules/role/role.service';
|
||||
import { GraphqlValidationExceptionFilter } from 'src/filters/graphql-validation-exception.filter';
|
||||
import { getRequest } from 'src/utils/extract-request';
|
||||
import { streamToBuffer } from 'src/utils/stream-to-buffer';
|
||||
|
||||
import { Workspace } from './workspace.entity';
|
||||
|
||||
import { WorkspaceService } from './services/workspace.service';
|
||||
|
||||
const OriginHeader = createParamDecorator(
|
||||
(data: unknown, ctx: ExecutionContext) => {
|
||||
const request = getRequest(ctx);
|
||||
|
||||
return request.headers['origin'];
|
||||
},
|
||||
);
|
||||
|
||||
@Resolver(() => Workspace)
|
||||
@UseFilters(
|
||||
GraphqlValidationExceptionFilter,
|
||||
@ -286,9 +300,31 @@ export class WorkspaceResolver {
|
||||
@Query(() => PublicWorkspaceDataOutput)
|
||||
@UseGuards(PublicEndpointGuard)
|
||||
async getPublicWorkspaceDataByDomain(
|
||||
@Args('origin') origin: string,
|
||||
@OriginHeader() originHeader: string,
|
||||
@Args('origin', { nullable: true }) origin?: string,
|
||||
): Promise<PublicWorkspaceDataOutput | undefined> {
|
||||
try {
|
||||
const systemEnabledProviders: AuthProviders = {
|
||||
google: this.twentyConfigService.get('AUTH_GOOGLE_ENABLED'),
|
||||
magicLink: false,
|
||||
password: this.twentyConfigService.get('AUTH_PASSWORD_ENABLED'),
|
||||
microsoft: this.twentyConfigService.get('AUTH_MICROSOFT_ENABLED'),
|
||||
sso: [],
|
||||
};
|
||||
|
||||
if (!origin) {
|
||||
return {
|
||||
id: 'default-workspace',
|
||||
logo: '',
|
||||
displayName: 'Default Workspace',
|
||||
workspaceUrls: {
|
||||
subdomainUrl: originHeader,
|
||||
customUrl: originHeader,
|
||||
},
|
||||
authProviders: systemEnabledProviders,
|
||||
};
|
||||
}
|
||||
|
||||
const workspace =
|
||||
await this.domainManagerService.getWorkspaceByOriginOrDefaultWorkspace(
|
||||
origin,
|
||||
@ -309,14 +345,6 @@ export class WorkspaceResolver {
|
||||
}
|
||||
}
|
||||
|
||||
const systemEnabledProviders: AuthProviders = {
|
||||
google: this.twentyConfigService.get('AUTH_GOOGLE_ENABLED'),
|
||||
magicLink: false,
|
||||
password: this.twentyConfigService.get('AUTH_PASSWORD_ENABLED'),
|
||||
microsoft: this.twentyConfigService.get('AUTH_MICROSOFT_ENABLED'),
|
||||
sso: [],
|
||||
};
|
||||
|
||||
return {
|
||||
id: workspace.id,
|
||||
logo: workspaceLogoWithToken,
|
||||
|
||||
Reference in New Issue
Block a user