add Ep receipt
This commit is contained in:
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@Injectable()
|
||||
export class JwtAuthGuard extends AuthGuard('jwt') {}
|
||||
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user