added new Ep to servicio and periodo
This commit is contained in:
@@ -27,6 +27,9 @@ export class UserService {
|
||||
const user = await this.userRepository.findOne({
|
||||
where: { usuario, password },
|
||||
});
|
||||
console.log(usuario);
|
||||
console.log(password);
|
||||
console.log(user);
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException(`El usuario o la contraseña es incorrecta`);
|
||||
@@ -38,7 +41,11 @@ export class UserService {
|
||||
async Login(data: Login, res: Response) {
|
||||
const user = await this.findOneByNameandPassword(data);
|
||||
|
||||
const payload = { id: user.id_usuario, usuario: user.usuario, role:user.perfil.perfil};
|
||||
const payload = {
|
||||
id: user.id_usuario,
|
||||
usuario: user.usuario,
|
||||
role: user.perfil.perfil,
|
||||
};
|
||||
const token = await this.jwtService.signAsync(payload);
|
||||
|
||||
res.cookie('token', token, {
|
||||
@@ -88,9 +95,9 @@ export class UserService {
|
||||
throw new NotFoundException('Perfil not found');
|
||||
}
|
||||
|
||||
const fecha_registro = new Date()
|
||||
const fecha_registro = new Date();
|
||||
|
||||
const datauser = { ...rest, perfil ,fecha_registro};
|
||||
const datauser = { ...rest, perfil, fecha_registro };
|
||||
|
||||
const usercreate = this.userRepository.create(datauser);
|
||||
return this.userRepository.save(usercreate);
|
||||
@@ -101,14 +108,17 @@ export class UserService {
|
||||
usuario: (await this.findOne(id_usuario)).usuario,
|
||||
password: data.password,
|
||||
});
|
||||
console.log(user);
|
||||
|
||||
user.password = data.newPassword;
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
async getAll(){
|
||||
|
||||
async getAll() {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
async getAllPerfil(){
|
||||
|
||||
async getAllPerfil() {
|
||||
return this.perfilRepository.find();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user