auth
This commit is contained in:
@@ -19,35 +19,31 @@ import { Key } from 'src/model/entitites';
|
||||
import { KeyHandoverPDFDataDto } from 'src/model/dto/key-handover.dto';
|
||||
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Controller('key')
|
||||
export class KeyController {
|
||||
constructor(private service: KeyService) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get()
|
||||
getKeys(@Req() req: AuthenticatedRequest) {
|
||||
return this.service.getUsersKeys(req.user);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('lost')
|
||||
getLostKeys(@Req() req: AuthenticatedRequest) {
|
||||
return this.service.getLostKeys(req.user);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Post()
|
||||
postKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
||||
return this.service.createKey(req.user, key);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Put()
|
||||
updateKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
||||
return this.service.updateKey(req.user, key);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Put(':id/restore')
|
||||
restoreKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||
return this.service.restoreKey(req.user, id);
|
||||
@@ -56,7 +52,6 @@ export class KeyController {
|
||||
|
||||
@Get(':id/handover/pdf')
|
||||
async getHandoverPDF(@Param('id') id: string, @Res() res: Response) {
|
||||
console.log("GET PDF")
|
||||
const { pdf, response } = await this.service.getPdf(id);
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
@@ -76,7 +71,6 @@ export class KeyController {
|
||||
res.end(pdf);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Post(':id/handover')
|
||||
handoutKey(
|
||||
@Req() req: AuthenticatedRequest,
|
||||
@@ -86,13 +80,11 @@ export class KeyController {
|
||||
return this.service.handoverKey(req.user, body, id);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get(':id/handover')
|
||||
getKeyHandouts(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||
return this.service.getKeyHandovers(req.user, id);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('archive')
|
||||
getArchive(@Req() req: AuthenticatedRequest) {
|
||||
return this.service.getDeletedKeys(req.user);
|
||||
@@ -100,7 +92,6 @@ export class KeyController {
|
||||
|
||||
@Post('pdf')
|
||||
async generatePdf(@Body() dto: KeyHandoverPDFDataDto, @Res() res: Response) {
|
||||
console.log("GENERATE PDF")
|
||||
const { pdf, response } = await this.service.createPdf(dto);
|
||||
|
||||
res.setHeader(
|
||||
@@ -121,7 +112,6 @@ export class KeyController {
|
||||
res.end(pdf);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Delete(':id')
|
||||
deleteKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||
return this.service.deleteKey(req.user, id);
|
||||
|
||||
@@ -29,11 +29,8 @@ export class KeyService {
|
||||
private readonly configService: ConfigService,
|
||||
private readonly mailService: MailService,
|
||||
private readonly sseService: SseService,
|
||||
private readonly httpService: HttpService,
|
||||
private readonly pdfService: PdfService
|
||||
) {
|
||||
console.log("INIT KEYSERVICE")
|
||||
}
|
||||
) { }
|
||||
|
||||
get isDevelopMode(): boolean {
|
||||
return (this.configService.get('DEVELOP_MODE') || '').toLowerCase() == 'true';
|
||||
|
||||
@@ -20,7 +20,6 @@ export class PdfService {
|
||||
public async generatePDF(dto: KeyHandoverPDFDataDto): Promise<{ pdf: Buffer, response: AxiosResponse}> {
|
||||
const h = await this.handoverRepo.findOneByOrFail({ id: dto.handoverId });
|
||||
const response = await this.post(`${this.STORAGESERVER}/pdf/keyhandover`, dto);
|
||||
console.log(response)
|
||||
if (response?.data == null) { return; }
|
||||
h.pdfFormKey = response.data;
|
||||
await this.handoverRepo.save(h);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Injectable()
|
||||
export class StorageService {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
console.log(configService.get('STORAGE_HOST'))
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user