
I want to create a role based application where there will be one user role and another one will be admin role. Admin will be able to add blogs to the website directly while the users have to send request to the admin via a contact form.
I haven't done this kind of thing before. It's gonna be a React app. So, need help and directions.

That's will probably be a more diffcult to demonstrate, but here's are main guidelines.
Teams & Rules Appwrite offers two ways to separate users.
A. Add them to teams https://appwrite.io/docs/client/teams https://appwrite.io/docs/client/teams?sdk=web-default#teamsCreateMembership
B. Add role to a user https://appwrite.io/docs/client/teams?sdk=web-default#teamsUpdateMembershipRoles
You can work your way around it without react, just by using pure js/ts with that logic.
Then, when you get the user object back from Appwrite using this function. (inside a function with a server SDK) https://appwrite.io/docs/server/users?sdk=nodejs-default#usersListMemberships Then you'll be able to filter the results back to frontend

Hi - adding to @Binyamin 's answer
So, for admin:
- Admin runs function "A" (suppose) and this function allows the admin to post the blog directly.
So, for user:
- User runs a function "B" and this function sends a call to a different function "C" which will act as the interface/connecting point between user and admin. Function C is called and it checks with admin for permissions, if the permission is granted, the function returns back to B and tells the user about permission being granted. Next lines in B are, using backend logic you can make the admin run their own logic of A to post the blog.
Does this logic help?
Using roles will be a very good help here.

logic is good but I might get stuck.

Let me first try with all users thing

After that I'll think about the admin role

How I would do it
- Create two collections (
posts
,posts_submissions
for users) - create admin team (
admin
) and add admin user to this team posts
permission -> any read, write:team:admin
posts_submissions
-> document security turned on, give create permission to any logged in users, and write permission toteam:admin
for document give read and write permissionuser:userId
(creator)- When user log in, check if they are admin via team membership
- If admin -> submit post should save to
posts
collection - if not admin -> submit post should save to
posts_submissions
collection For this all you need to change is the collection ID based on if user is admin and server side permissions will validate if user try to mess around - you can make a admin panel where admins can see lists of posts in
posts_submission
and when they click publish/accept -> create onposts
and delete fromposts_submissions

Great! I'll try this out

Do you like this solution ?

Yes

Let me know how it goes when you do.

pretty much the same thing I do for my mobile app. +1

Sure!

Hi @Susmita shall we close this if its resolved?

Close this. I'll open later on if needed. Currently not working with roles.

[CLOSED] How to create a role based application?
Recommended threads
- mcp-for-docs not working properly
I'm experiencing issues integrating the MCP server tool with Cursor IDE. The MCP server connection establishes successfully initially but fails after one minute...
- Creating a relationship with nested obje...
{ "data": { "name": "DiDi", "type": "Software Development", "userJobs": [{ "$id": "68cbf1e2003612fb13ca", "j...
- Realtime integration with SSR auth
Hey, I have a nextjs website with SSR auth, works great. I use a session client for user verification and an admin client with API key. Both is used with node-...
