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

Resources and Roles Lists are empty Objects #18

Open
chandanchhajerintech opened this issue Sep 26, 2024 · 1 comment
Open

Resources and Roles Lists are empty Objects #18

chandanchhajerintech opened this issue Sep 26, 2024 · 1 comment

Comments

@chandanchhajerintech
Copy link

Here is my code

import IAM, { Resource, Role, Group, User, Right } from '@author.io/iam';

IAM.createResource('user', ['create', 'read', 'update', 'delete', 'list'])
IAM.createResource('task', ['create', 'read', 'update', 'delete', 'list'])

IAM.createRole('admin', {
  'user': ['create', 'read', 'update', 'delete', 'list'],
  'task': ['create', 'read', 'update', 'delete', 'list'],
})

console.log(await IAM.resources)
console.log(await IAM.roles)

Output is
[ Resource {}, Resource {} ]
[ Role {}, Role {} ]

Issue: Resources and Roles are creating but not getting in the list. Output have blank objects.
Can anyone provide the solution for this?

@chandanchhajerintech
Copy link
Author

chandanchhajerintech commented Sep 27, 2024

Finally I got the solution. Below code resolve my issue.

let allResources = IAM.resources.map(resource => resource.data);
let allRoles = IAM.roles.map(role => role.data);

console.log(JSON.stringify(allRoles))
console.log(JSON.stringify(allRoles))

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

1 participant