mirror of
https://github.com/docmost/docmost.git
synced 2025-11-19 14:41:10 +10:00
* Make JwtGuard better
* Fix auth decorators
This commit is contained in:
@ -7,36 +7,29 @@ import {
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { JwtUser } from '../../decorators/jwt-user.decorator';
|
||||
import { WorkspaceService } from '../workspace/services/workspace.service';
|
||||
import { JwtGuard } from '../auth/guards/JwtGuard';
|
||||
import { JwtGuard } from '../auth/guards/jwt.guard';
|
||||
import { SearchService } from './search.service';
|
||||
import { SearchDTO } from './dto/search.dto';
|
||||
import { CurrentWorkspace } from '../../decorators/current-workspace.decorator';
|
||||
import { Workspace } from '../workspace/entities/workspace.entity';
|
||||
|
||||
@UseGuards(JwtGuard)
|
||||
@Controller('search')
|
||||
export class SearchController {
|
||||
constructor(
|
||||
private readonly searchService: SearchService,
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
) {}
|
||||
constructor(private readonly searchService: SearchService) {}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post()
|
||||
async pageSearch(
|
||||
@Query('type') type: string,
|
||||
@Body() searchDto: SearchDTO,
|
||||
@JwtUser() jwtUser,
|
||||
@CurrentWorkspace() workspace: Workspace,
|
||||
) {
|
||||
const workspaceId = (
|
||||
await this.workspaceService.getUserCurrentWorkspace(jwtUser.id)
|
||||
).id;
|
||||
|
||||
if (!type || type === 'page') {
|
||||
return this.searchService.searchPage(
|
||||
searchDto.query,
|
||||
searchDto,
|
||||
workspaceId,
|
||||
workspace.id,
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
@ -2,11 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { SearchController } from './search.controller';
|
||||
import { SearchService } from './search.service';
|
||||
import { AuthModule } from '../auth/auth.module';
|
||||
import { WorkspaceModule } from '../workspace/workspace.module';
|
||||
import { PageModule } from '../page/page.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule, WorkspaceModule, PageModule],
|
||||
imports: [AuthModule, PageModule],
|
||||
controllers: [SearchController],
|
||||
providers: [SearchService],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user