Closed necm1 closed 1 year ago
Hi @necm1 thanks for using rbac
. I suppose it should be injectable, see example below:
@Injectable() <------------------------- IT'S REQUIRED
export class AsyncService implements IDynamicStorageRbac {
constructor(
@Optional() @Inject('ICacheRBAC')
private readonly cache?: ICacheRBAC,
){
}
async getRbac(): Promise<IStorageRbac> {
return new Promise((resolve) => {
resolve(RBAC);
});
}
Hello!
I am facing the same issue in the same usecase, but my DynamicRbacService
is already marked @Injectable()
. Could you please suggest what am I doing wrong?
My UserModule
(is not the root one):
@Module({
imports: [
RBAcModule.forDynamic(DynamicRbacService,),
],
providers: [DynamicRbacService, AccessDefinitionRepository],
})
export class UserModule {}
where DynamicRbacService
is:
@Injectable()
export class DynamicRbacService implements IDynamicStorageRbac {
constructor(private readonly repository: AccessDefinitionRepository) {}
Error is this:
Nest can't resolve dependencies of the StorageRbacService (?, DynamicRbacService). Please make sure that the argument ModuleRef at index [0] is available in the RBAcModule context.
Hello @Vitaliy-Svinchyak, I got this issue. It's hell, because all my tests work nice. but if we import rbac from node_modules, this issued occurs. I'll think why. Thanks. You can use rbac with fromDynamic as own library. It means to move from node_modules to local
@Vitaliy-Svinchyak @necm1 Hello, good news v1.8.4
- works fine but pay attention to supporting version,
Support: NestJS ^8.0.0 || ^9.0.0
. Thanks!
@sergey-telpuk Thank you a lot!
Funny thing is that this fix is working fine with npm. But with yarn when nodeLinker: "pnp"
is enabled it is failing with the same issue. But nvm, I will just switch to the nodeLinker: "node-modules"
. Thank you for fix!
Same thing, still encountering the error
Hi @ogheneovo12 fixed v1.9
Hi!
I was trying to use this package, but I'm facing following error:
It seems like Nest cannot resolve following line: https://github.com/sergey-telpuk/nestjs-rbac/blob/master/src/services/storage.rbac.service.ts#L10
PermissionService:
Actually I didn't make it injectable, because I cannot even use dependency injection inside it. It tries to create a new instance of
PermissionService
while the other 2 paramters are optional forproviders
&imports
. It doesn't really make sene for me or it's just not implemented yet.PermissionService.rbac
has following value (it's actually filled with values from the database):Module: