cambios
This commit is contained in:
@@ -56,7 +56,8 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async encriptar(password) {
|
||||
return await bcrypt.hash(password);
|
||||
const saltRounds = 10;
|
||||
return await bcrypt.hash(password,saltRounds);
|
||||
}
|
||||
|
||||
async generarPassword() {
|
||||
|
||||
+10
@@ -1,9 +1,19 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true, // elimina propiedades que no existan en el DTO
|
||||
transform: true, // permite que @Type() funcione
|
||||
transformOptions: { enableImplicitConversion: true }, // convierte strings → number/date
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
app.enableCors();
|
||||
await app.listen(process.env.APP_PORT ?? 3000);
|
||||
console.log(
|
||||
|
||||
@@ -19,14 +19,17 @@ export class UpdateServicioDto {
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaInicio debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaInicio?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaFin debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaFin?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaNacimiento debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaNacimiento?: Date;
|
||||
|
||||
@IsOptional()
|
||||
|
||||
@@ -174,6 +174,8 @@ export class ServicioController {
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const data = JSON.parse(dataJson);
|
||||
|
||||
return this.servicioService.update(data, files);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class UsuarioController {
|
||||
}
|
||||
|
||||
@Post('new-password-alumno/:idServicio')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
//@UseGuards(AuthGuard('jwt'))
|
||||
async newPasswordAlumno(
|
||||
@Param('idServicio', ParseIntPipe) idServicio: number,
|
||||
) {
|
||||
|
||||
@@ -145,7 +145,7 @@ export class UsuarioService {
|
||||
}
|
||||
|
||||
async newPasswordAlumno(idServicio: number) {
|
||||
const password = this.authService.generarPassword();
|
||||
const password = await this.authService.generarPassword();
|
||||
|
||||
// Buscar el servicio junto con el usuario
|
||||
const servicio = await this.servicioRepo.findOne({
|
||||
@@ -164,6 +164,7 @@ export class UsuarioService {
|
||||
}
|
||||
|
||||
// Preparar correo
|
||||
const { preRegistro } = require('../helpers.services/msjCorreos');
|
||||
let correo = preRegistro(password, usuario.nombre);
|
||||
|
||||
// Enviar correo
|
||||
@@ -184,10 +185,10 @@ export class UsuarioService {
|
||||
}
|
||||
|
||||
async newPasswordResponsable(idUsuario: number) {
|
||||
const password = this.authService.generarPassword();
|
||||
const password = await this.authService.generarPassword();
|
||||
|
||||
// Buscar usuario
|
||||
const usuario = await this.userRepo.findOne({ where: { idUsuario } });
|
||||
const usuario = await this.userRepo.findOne({ where: { idUsuario },relations: ['tipoUsuario'] });
|
||||
|
||||
if (!usuario) {
|
||||
throw new NotFoundException('No existe este Usuario.');
|
||||
@@ -197,7 +198,10 @@ export class UsuarioService {
|
||||
throw new BadRequestException('Este usuario no es de tipo responsable.');
|
||||
}
|
||||
|
||||
|
||||
// Preparar correo
|
||||
const { enviarSec } = require('../helpers.services/msjCorreos');
|
||||
|
||||
const correo = enviarSec(password, usuario.usuario, usuario.nombre);
|
||||
|
||||
// Enviar correo
|
||||
|
||||
Reference in New Issue
Block a user