Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForRootAsync is not working #86

Open
raksrivastava opened this issue Nov 25, 2022 · 1 comment
Open

ForRootAsync is not working #86

raksrivastava opened this issue Nov 25, 2022 · 1 comment

Comments

@raksrivastava
Copy link

raksrivastava commented Nov 25, 2022

ForRootAsync is not working. I have written it in app.module.ts.

   AccessControlModule.forRootAsync({
       inject: [RolePermissionsService],
      useFactory: async (roleService: RolePermissionsService): Promise<RolesBuilder> => {
        return new RolesBuilder(await roleService.getAll());
      },
    }), 

roleService.getAll() return result as below array.

 [
    { role: 'admin', resource: 'video', action: 'create:any', attributes: '*, !views' },
    { role: 'admin', resource: 'video', action: 'read:any', attributes: '*' },
    { role: 'admin', resource: 'video', action: 'update:any', attributes: '*, !views' },
    { role: 'admin', resource: 'video', action: 'delete:any', attributes: '*' },

    { role: 'user', resource: 'video', action: 'create:own', attributes: '*, !rating, !views' },
    { role: 'user', resource: 'video', action: 'read:any', attributes: '*' },
    { role: 'user', resource: 'video', action: 'update:own', attributes: '*, !rating, !views' },
    { role: 'user', resource: 'video', action: 'delete:own', attributes: '*' }
];

i am getting this error.
image

@shekohex
Copy link
Member

shekohex commented Nov 26, 2022

The error says it can't find the RolePermissionsService, do you have that service exported from other modules?

Revisit this part again: https://github.com/nestjsx/nest-access-control#forrootasync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants