Organization access control

Hello! In my app there are different articles which can have different languages, countries and cities. Only users with the correct list of permissions should be able to edit a post. Would every country-city-language pair have to be its own organization? Or is there a better way to do this? What about sharing editing access with another user? Would there have to be a new organization for each post? https://www.better-auth.com/docs/plugins/organization#list-users-organizations
Organization | Better Auth
The organization plugin allows you to manage your organization's members and teams.
4 Replies
Kazz
Kazz5mo ago
I think you might find your answer in the Access Control part of the plugin https://www.better-auth.com/docs/plugins/organization#access-control
Organization | Better Auth
The organization plugin allows you to manage your organization's members and teams.
PIat
PIatOP5mo ago
Hi! Thank you for the hint! I guess I will map it so that each post will have its own organization behind the scenes Do you know whether the "project" key can be arbitrary?
Kazz
Kazz5mo ago
I haven't used the Access Control feature yet, but I suppose you can go with any key you want as long as its consistent (Could be wrong so dont take my word for it)
import { createAccessControl, defaultStatements} from 'better-auth/plugins/access'

const Posts = {
...defaultStatements,
anything: ['create', 'share', 'update', 'delete'],
} as const

const ac = createAccessControl(Posts)

const member = ac.newRole({
anything: ['create'],
})
import { createAccessControl, defaultStatements} from 'better-auth/plugins/access'

const Posts = {
...defaultStatements,
anything: ['create', 'share', 'update', 'delete'],
} as const

const ac = createAccessControl(Posts)

const member = ac.newRole({
anything: ['create'],
})
PIat
PIatOP5mo ago
Thank you, I'll try now!

Did you find this page helpful?