These are the different types of users in my app: ```export const enum USER_TYPE {
SUPER_ADMIN = 'SUPER_ADMIN',
ADMIN = 'ADMIN',
COMPANY_ADMIN = 'COMPANY_ADMIN',
STORE_ADMIN = 'STORE_ADMIN',
MANAGER = 'MANAGER',
}
export const USER_TYPE_ORDER = {
SUPER_ADMIN: 1,
ADMIN: 2,
COMPANY_ADMIN: 3,
STORE_ADMIN: 4,
MANAGER: 5,
};
The AppAbility file code: ```
export function defineAbilitiesFor(user) {
const { can, build } = new AbilityBuilder(createMongoAbility);
if (user.role === USER_TYPE.SUPER_ADMIN) {
can('manage', 'all');
} else if (user.role === USER_TYPE.ADMIN) {
can('create', user, { userType: { $gte: USER_TYPE_ORDER.ADMIN } });
} else if (user.role === USER_TYPE.COMPANY_ADMIN) {
can('create', user, { userType: { $gte: USER_TYPE_ORDER.COMPANY_ADMIN } });
} else if (user.role === USER_TYPE.STORE_ADMIN) {
can('create', user, { userType: { $gte: USER_TYPE_ORDER.STORE_ADMIN } });
} else if (user.role === USER_TYPE.MANAGER) {
}
return build();
}
User creation logic: ADMIN user can create users such as COMPANY_ADMIN, STORE_ADMIN, MANAGER, but COMPANY_ADMIN cannot create ADMIN or SUPER_ADMIN, and so on and so forth. but this is not working instead it throws Forbidden error. I am currently logged in as an ADMIN user and trying to create a COMPANY_ADMIN user but not working.