refactor: the whole role and permission flow
This commit is contained in:
@@ -3,7 +3,6 @@ import { FindOptionsWhere, In, IsNull } from "typeorm";
|
||||
|
||||
import { ParamDto } from "../../../common/DTO/param.dto";
|
||||
import { CategoryMessage, CommonMessage, ServiceMessage } from "../../../common/enums/message.enum";
|
||||
import { RoleEnum } from "../../users/enums/role.enum";
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { CategoryListSearchQueryDto, CategorySearchQueryDto } from "../DTO/category-search-query.dto";
|
||||
import { CreateCategoryDto } from "../DTO/create-category.dto";
|
||||
@@ -173,10 +172,9 @@ export class DanakServicesService {
|
||||
}
|
||||
/******************************************** */
|
||||
|
||||
async getDanakServiceByIdWithSubs(serviceId: string, roles: RoleEnum[]) {
|
||||
const hasAccess = roles.includes(RoleEnum.ADMIN);
|
||||
async getDanakServiceByIdWithSubs(serviceId: string, isAdmin: boolean) {
|
||||
const danakService = await this.danakServicesRepository.findOne({
|
||||
where: { id: serviceId, ...(hasAccess && { isActive: true, subscriptionPlans: { isActive: true } }) },
|
||||
where: { id: serviceId, ...(isAdmin && { isActive: true, subscriptionPlans: { isActive: true } }) },
|
||||
relations: { images: true, subscriptionPlans: true },
|
||||
});
|
||||
if (!danakService) throw new BadRequestException(ServiceMessage.SERVICE_NOT_FOUND_BY_ID);
|
||||
|
||||
Reference in New Issue
Block a user