Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!38
This commit is contained in:
commit
9ff383c3b2
|
@ -116,13 +116,15 @@ export class TransactionController {
|
|||
|
||||
@Get('deposit-return')
|
||||
async findDepositReturn(@Query('page') page: number, @Request() req) {
|
||||
const data = await this.transactionService.getAllDepositReturnFromUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
);
|
||||
const [data, count] =
|
||||
await this.transactionService.getAllDepositReturnFromUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
);
|
||||
|
||||
return {
|
||||
...data,
|
||||
data,
|
||||
count,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
|
@ -133,13 +135,15 @@ export class TransactionController {
|
|||
@Query('page') page: number,
|
||||
@Request() req,
|
||||
) {
|
||||
const data = await this.transactionService.getAllDepositReturnToUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
);
|
||||
const [data, count] =
|
||||
await this.transactionService.getAllDepositReturnToUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
);
|
||||
|
||||
return {
|
||||
...data,
|
||||
data,
|
||||
count,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
|
|
|
@ -207,6 +207,19 @@ export class UsersController {
|
|||
};
|
||||
}
|
||||
|
||||
@Put('change-password/:id')
|
||||
async updatePassword(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@Request() req,
|
||||
@Body() updateUserDto: UpdateUserDto,
|
||||
) {
|
||||
return {
|
||||
data: await this.usersService.updatePassword(id, updateUserDto, req.user),
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async remove(@Param('id', ParseUUIDPipe) id: string) {
|
||||
await this.usersService.remove(id);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user