ultima versión
This commit is contained in:
+12
-28
@@ -2,23 +2,14 @@ import {
|
||||
Controller,
|
||||
Post,
|
||||
Body,
|
||||
UploadedFile,
|
||||
Headers,
|
||||
UnauthorizedException,
|
||||
Get,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { MailService } from './mail.service';
|
||||
import { ExcelService } from 'src/excel/excel.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiSendMail} from './mail.decorators';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Sistema } from 'src/typeorm/entidades';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { SistemaService } from 'src/sistema/sistema.service';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { SendCorreoDto } from 'src/mail/dto/send-email.dto';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { AuthService } from 'src/auth/auth.service';
|
||||
|
||||
|
||||
@@ -47,26 +38,19 @@ export class MailController {
|
||||
if (!headers.token) {
|
||||
throw new UnauthorizedException('Header "token" es requerido');
|
||||
}
|
||||
let payload
|
||||
|
||||
payload = await this.authService.verificarToken(headers.token);
|
||||
|
||||
|
||||
if (!payload || !payload.nombre) {
|
||||
throw new UnauthorizedException('Token inválido o incompleto');
|
||||
}
|
||||
|
||||
const sistem= await this.sistemaService.findByNombre(payload.nombre)
|
||||
|
||||
|
||||
if(!sistem){
|
||||
throw new UnauthorizedException('sistema No encontrado');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const result = await this.mailService.sendMail(body,sistem); // sistem
|
||||
const result =
|
||||
await this.mailService.sendMail(body,headers.token)
|
||||
.then((value) => {
|
||||
console.log("ya acabe el correo", value);
|
||||
|
||||
})
|
||||
.catch((err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
|
||||
// sistem
|
||||
return result;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user