add: change password
This commit is contained in:
		| @@ -313,6 +313,34 @@ export class UsersService { | ||||
|     return userData; | ||||
|   } | ||||
|  | ||||
|   async updatePassword( | ||||
|     id: string, | ||||
|     updateUserDto: UpdateUserDto, | ||||
|     currentUser: any, | ||||
|   ) { | ||||
|     try { | ||||
|       const dataUser = await this.usersRepository.findOneOrFail(id); | ||||
|       dataUser.password = await hashPassword( | ||||
|         updateUserDto.password, | ||||
|         dataUser.salt, | ||||
|       ); | ||||
|       const result = await this.usersRepository.save(dataUser); | ||||
|       return dataUser; | ||||
|     } catch (e) { | ||||
|       if (e instanceof EntityNotFoundError) { | ||||
|         throw new HttpException( | ||||
|           { | ||||
|             statusCode: HttpStatus.NOT_FOUND, | ||||
|             error: 'User not found', | ||||
|           }, | ||||
|           HttpStatus.NOT_FOUND, | ||||
|         ); | ||||
|       } else { | ||||
|         throw e; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   setStatus = async (id: string, type: string) => { | ||||
|     const userData = new User(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user