Back

[SOLVED] Format permissions individually

  • 2
  • Flutter
ireneus
14 Feb, 2023, 10:26

Does the sdk provide any method to format permissions? the permissions return object shows them currently as complete strings, if not whats a good alternative for now?

TL;DR
The user is asking for help with formatting permissions individually in a support thread. They provide some code and ask for a solution. Another user suggests parsing the permissions using regex expressions. The original poster mentions the order of the permissions and the need for UI content. There is no clear solution provided in the thread.
Eldad
14 Feb, 2023, 10:30

We don't have a good solution for this, beside parsing them unless @Meldiron or @Steven have some ideas.

Anyways, this is something we really want to improve, how would you expect the SDK to handle this? Would some extra methods help? which?

Meldiron
14 Feb, 2023, 10:31

Hey 👋 I cant think of any simple way from top of my head. Extra question, what is your use case - why do you need to parse them? Ideally you should not be required to work with those.

ireneus
14 Feb, 2023, 10:32

im thinking of using regex expressions but thinking further they dont come in expected orders

ireneus
14 Feb, 2023, 10:33

i want to show ui content for perms + roles

Meldiron
14 Feb, 2023, 10:36

That sounds reasonable. Well this is the structure:

TypeScript
TYPE("ROLE")

Where TYPE can be read,write,create,update,delete and role can be:

  • any
  • guests
  • users or users/USER_ID or users/USER_ID:STATUS (status can be verified or unverified)
  • member:MEMBERSHIP_ID
  • team:TEAM_ID or team:TEAM_ID/ROLE

Does that help? parsing with regex should be a good way to separate type and role. From there, you check what kind of role you have with a few ifs

Meldiron
14 Feb, 2023, 10:37
ireneus
14 Feb, 2023, 10:38

you are awesome thanks

ireneus
15 Feb, 2023, 18:11

@Eldad @Meldiron @Steven this can be refined in many ways but ill leave that up for you guys to decide i gotta work on my project :appwriteheart2: just make sure to keep the iserror value and turn it to true when there is an actual error.

ireneus
16 Feb, 2023, 17:31

[SOLVED] Format permissions individually

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more