AccessControl casbin MemoryAdapter

I'm following tutorial from this https://refine.dev/docs/advanced-tutorials/access-control/#adding-policy-and-model However, in Adding Policy and Model.
export const adapter = new MemoryAdapter(`
p, editor, posts, list
`);
export const adapter = new MemoryAdapter(`
p, editor, posts, list
`);
Where does the MemoryAdapter come from?
kapa.ai
kapa.ai252d ago
Hi @tads8799. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry for the confusion, but it seems there's a mistake in the documentation you're following. The MemoryAdapter should be imported from the "casbin" library, similar to how the newModel function is imported. However, this import statement is not shown in the provided extracts. I recommend checking the official Casbin documentation or their GitHub repository for the correct usage and import statements. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai252d ago
<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below
sensitive-blue
sensitive-blue252d ago
The full example code is like this:
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new MemoryAdapter(`
p, editor, posts, list
`);
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new MemoryAdapter(`
p, editor, posts, list
`);
@kapa.ai
kapa.ai
kapa.ai252d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The MemoryAdapter in your code is used to define the policy for the Casbin enforcer. It seems like there's a mistake in your code. You've imported StringAdapter from "casbin" but you're using MemoryAdapter which is not imported. If you want to use MemoryAdapter, you should import it from "casbin". If MemoryAdapter is not available in "casbin", you might want to use StringAdapter instead, as you've already imported it. Here's how your code should look like if you want to use StringAdapter:
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new StringAdapter(`
p, editor, posts, list
`);
import { newModel, StringAdapter } from "casbin";

export const model = newModel(`
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
`);

export const adapter = new StringAdapter(`
p, editor, posts, list
`);
Please check the official Casbin documentation for the correct usage and import statements. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai252d ago
<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below
sensitive-blue
sensitive-blue252d ago
I understand
More Posts
could not find the login username and password of the examples/pixels-admin, any clues?I am trying to find a complete example about casbin for RBAC, there are only two in the official exaImport Exceli have groups and contacts resources. groups can get many contacts. i wish to add a button on each gdropdown in sidebar with chakra uiHello i'm trying to create a dropdown button (parent) with its sub items (childen) yet i didn't findHey,I have a resource call groups. i wish to make crud from my rest api any helps to how i can archieveForm not loading api values@kapa.ai <Form.Item label={t('pages.marketMaker.addLoan.systemBalance')} name="@kapa.ao<Title level={5}> {"title"} </Title> <Title level={5}> {"title2"} </TitlShow show data on List pageI want a page to appeared on the Menu, but instead of List page by default. I wanna use the show datparent resource permissionI have two resource under a parent named settings. here settings is not an actual resource but we seswizzle create form RefinePageHeaderClassNames is not defineddefault generate is not properly workingSet Null as default value in useSelect``` const { selectProps } = useSelect<IUser>({ resource: "users", optionLabel: "name", accessControlProvider is set first but login is done afterwards so I get role afterwardsaccessControlProvider is set first but login is done afterwards so I get role afterwardsset a global stateset a global state variableProblem with using Autocomplete MUIThere are no errors when using Inferencer. As soon as I create the page, an error occurs.Make resource dynamic?Can we make resources dynamic according to user role?UI framework recommendationAre there any recommendations about UI frameworks for refine? Which one has best support by refine ahow to code Edit form with Chakra RadioGroup form componentunable to populate default value of radiowarnWhenUnsavedChangesin my create page I have a few mui elemenets and my own custom element. i passed warnWhenUnsavedChanInferencer customize queryHello! Can someone please tell me how I can customize the request in the Inferencer for graphql quer