movimiento log tipo admnin desde el payload, solo en verificacion de excel
This commit is contained in:
@@ -22,6 +22,6 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
|
||||
async validate(payload: any) {
|
||||
// Devuelve lo que estará disponible en Request.user
|
||||
return { userId: payload.sub, email: payload.email, origen: payload.tipo };
|
||||
return { userId: payload.sub, email: payload.email, origen: payload.tipo, tipo: payload.tipo, };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,29 @@ export class ExcelController {
|
||||
private readonly movimientoService: MovimientoService,
|
||||
) { }
|
||||
|
||||
@Post('verify')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
@ExcelDocumentation.verifyExcel()
|
||||
async verifyExcel(@UploadedFile() file: Express.Multer.File, @Request() req) {
|
||||
const userId: number = req.user.userId; // ahora sí existe
|
||||
const errors = await this.excelService.validateFile(file.buffer);
|
||||
await this.movimientoService.log(
|
||||
// excel.controller.ts
|
||||
|
||||
@Post('verify')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
@ExcelDocumentation.verifyExcel()
|
||||
async verifyExcel(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Request() req
|
||||
) {
|
||||
const { userId, tipo } = req.user; // obtenemos ambos
|
||||
const errors = await this.excelService.validateFile(file.buffer);
|
||||
|
||||
await this.movimientoService.log(
|
||||
userId, // el ID
|
||||
tipo, // aquí va tu fuente dinámica
|
||||
errors.length ? 'FAILED' : 'SUCCESS',
|
||||
errors.join('; ')
|
||||
);
|
||||
|
||||
return { valid: errors.length === 0, errors };
|
||||
}
|
||||
|
||||
'VERIFY',
|
||||
errors.length ? 'FAILED' : 'SUCCESS',
|
||||
errors.join('; ')
|
||||
);
|
||||
return { valid: errors.length === 0, errors };
|
||||
}
|
||||
|
||||
@Post('load')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
|
||||
Reference in New Issue
Block a user