|
|
|
@ -119,7 +119,7 @@ export class UsersService { |
|
|
|
|
throw new HttpException("User not found.", HttpStatus.NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
await this.userModel.update({ refreshToken: null }, { where: { id: userId } }); |
|
|
|
|
return{message:"logout is successful"} |
|
|
|
|
return { message: "logout is successful" }; |
|
|
|
|
} |
|
|
|
|
//get information user method
|
|
|
|
|
async getProfile(userId: number): Promise<User> { |
|
|
|
@ -176,4 +176,17 @@ export class UsersService { |
|
|
|
|
throw new HttpException("An unexpected error occurred while fetching user information.", HttpStatus.INTERNAL_SERVER_ERROR); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//delete a specific user by admin
|
|
|
|
|
async deleteUser(userId: number) { |
|
|
|
|
const user = await this.userModel.findOne({ |
|
|
|
|
where: { id: userId }, |
|
|
|
|
}); |
|
|
|
|
if (!user) { |
|
|
|
|
throw new HttpException("User not found.", HttpStatus.NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
await this.userModel.destroy({ |
|
|
|
|
where: { id: userId }, |
|
|
|
|
}); |
|
|
|
|
return { message: "user deleted successful" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|