add Ep receipt

This commit is contained in:
2025-09-19 17:15:05 -06:00
parent 2f1b0cc76b
commit 0a27caf7ed
24 changed files with 160 additions and 148 deletions
+4
View File
@@ -1,4 +1,5 @@
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
import { Recibo } from 'src/recibo/entities/recibo.entity';
import {
Column,
Entity,
@@ -58,4 +59,7 @@ export class User {
(id_detalle_servicio) => id_detalle_servicio.id_perfil,
)
detalles_servicio: DetalleServicio[];
@OneToMany(() => Recibo, (recibo) => recibo.user)
recibo: Recibo[];
}
+5
View File
@@ -0,0 +1,5 @@
import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {}
+2 -2
View File
@@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { UserService } from './user.service';
import { ConfigService } from '@nestjs/config';
@Injectable()
@@ -15,6 +14,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
}
async validate(payload: any) {
return { userId: payload.id, username: payload.usuario };
console.log('payload:', payload);
return { id: payload.id, usuario: payload.usuario };
}
}
+3 -4
View File
@@ -21,11 +21,10 @@ import { JwtStrategy } from './jwt.strategy';
signOptions: { expiresIn: '1h' },
};
},
}),
],
controllers: [UserController],
providers: [UserService,JwtStrategy],
exports: [UserService],
providers: [UserService, JwtStrategy],
exports: [UserService,PassportModule,JwtModule],
})
export class UserModule { }
export class UserModule {}
+15 -2
View File
@@ -41,7 +41,20 @@ export class UserService {
path: '/',
});
return res.json({ message: 'Inicio de sesión exitoso' });
return res.json({
message: 'Inicio de sesión exitoso',
access_token: token,
});
}
async findOne(id_usuario: number): Promise<User> {
const student = await this.userRepository.findOne({
where: { id_usuario },
});
if (!student) {
throw new NotFoundException(`Student not found`);
}
return student;
}
}
//IO
//IO