Search code examples
permissionsschemarelationshipsstackmob

stackmob schemas and permissions


I have a structure I am after, but I can't quite pin down how I would set it up with stackmob permissions and schemas.

-Users (userID,username,password) I want users to be able to have friends, so I created a "relationship" for the schema called friends. It is a "one to many" relationship, associated with other users, and is indexed.

OK, so we are off to a good start...

Now I want a new schema

-Objects

Here is where it gets tricky...

I want logged in users to be able to create objects. I want the owner of the object and the owners friends to be able to read the object. I want the owner to be able to update the object, and the owner to delete.

C - owner (simple, set to owner)

R - owner AND friends (how?)

U - owner(simple, set to owner)

D - owner(simple, set to owner)

How do I set the read permissions so that the owners friends can read?


Solution

  • Currently you can't set permissions for the owner as well as a relationship. You can only choose one or the other. The workaround is to add the owner to the list of friends, and then set read permissions to the friends relationship.

    More information on allowing permissions for relationships can be found in StackMob's documentation: https://www.stackmob.com/devcenter/docs/Access-Controls:-Schema-Permissions#a-related_users_on_the_sm_owner_instance