chore: fetch ticket that only assing to a admin and only super admin can see all ticket
This commit is contained in:
@@ -376,12 +376,7 @@ export class UsersService {
|
||||
///****************************************************** */
|
||||
|
||||
async updateUserPassword(userId: string, newPassword: string) {
|
||||
const updatedUser = await this.userRepository.update(
|
||||
{ id: userId },
|
||||
{
|
||||
password: newPassword,
|
||||
},
|
||||
);
|
||||
const updatedUser = await this.userRepository.update({ id: userId }, { password: newPassword });
|
||||
return {
|
||||
updatedUser,
|
||||
};
|
||||
@@ -396,7 +391,13 @@ export class UsersService {
|
||||
|
||||
return { users };
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
async isSuperAdmin(adminId: string) {
|
||||
const user = await this.userRepository.findOne({ where: { id: adminId }, relations: { roles: true } });
|
||||
if (!user) throw new BadRequestException(UserMessage.USER_NOT_FOUND);
|
||||
return user.roles.some((role) => role.name === RoleEnum.SUPER_ADMIN);
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
async getCustomers(queryDto: SearchCustomersDto) {
|
||||
@@ -667,13 +668,7 @@ export class UsersService {
|
||||
/************************************************************ */
|
||||
|
||||
async getCustomersCount() {
|
||||
const count = await this.userRepository.count({
|
||||
where: {
|
||||
roles: {
|
||||
name: RoleEnum.USER,
|
||||
},
|
||||
},
|
||||
});
|
||||
const count = await this.userRepository.count({ where: { roles: { name: RoleEnum.USER } } });
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user