fixed update user
This commit is contained in:
@@ -73,13 +73,18 @@ export class AuthService {
|
||||
}
|
||||
|
||||
//update user
|
||||
async update(id_usuario, data:registerDto) {
|
||||
async update(id_usuario: number, data: registerDto) {
|
||||
const { contraseña } = data;
|
||||
|
||||
const{contraseña}=data;
|
||||
|
||||
if(contraseña){
|
||||
if (contraseña) {
|
||||
const hashedpassword = await hash(contraseña, 10);
|
||||
data = {...data,contraseña:hashedpassword};
|
||||
data = { ...data, contraseña: hashedpassword };
|
||||
} else {
|
||||
const user = await this.userRepository.findOne({ where: { id_usuario } });
|
||||
if (!user) {
|
||||
throw new HttpException('User not found', 404);
|
||||
}
|
||||
data = { ...data, contraseña: user.contraseña };
|
||||
}
|
||||
|
||||
return await this.userRepository.update(id_usuario, data);
|
||||
@@ -108,7 +113,7 @@ export class AuthService {
|
||||
throw new UnauthorizedException('Token has expired');
|
||||
}
|
||||
|
||||
return user;
|
||||
return ;
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException('validation token failed');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user