简体   繁体   中英

Parse Users with Roles

I'm try to get my head around this concept of how best to implement this via Parse.

Personal Training App

A studio get the app to manage their clients and their trainers.

Hence we have roles.

  1. The Studio Manager This user can look at all the data in the app, they can edit clients details, add clients etc. They can importantly look at all the trainers and see how many clients they have seen etc.

  2. The Trainers This user can only have access to the sessions they perform, they cannot see how many clients the other trainers are seeing. The trainer role is just for that specific trainer.

So how is the accomplished ?

I assume the Manger sets up his app, and then creates the User accounts that are linked to his account? I guess this would be done with a Create User Screen, where a manager can create Trainers. However trainers will not be able to have this option. There role would be ie Trainer, so the create new user screen will not be an option.

How for example is the link between the Manager User and their Trainers maintained. Because there will be many Managers setting up accounts, with many trainers. How are these relations best set up ? I dont want Managers in one studio being able to see all the details of another studio etc.

Is this just as simple as having the Managers User a "property" of all the other Users (his trainers) so he can only fetch and view those users?

Then you get to the ACL vs the CLP - i think that class level will be suitable for my app? This provides a comparison of the 2

Sorry for the long winded question, but any advice will be great. This post gave me some ideas...

Create ACL group called: Managers. All new managers should be added there.

And for each new data into your all you'll set ACL permission like this:

"Client Apple" => "ACL":{"managers":{"read":true},{"write":true},"trainer ObJectId:",{"read":true}}

Managers can read an write this client and only the trainer who has created this client could read it.

Client *privateData = [PFObject objectWithClassName:@"Client"];
private.name = @"Client Apple";

PFACL *acl = [PFACL ACLWithUser:[PFUser currentUser]];
[acl setPublicWriteAccess:NO];
[acl setPublicReadAccess:NO];
[acl setWriteAccess:YES forUser:[PFUser currentUser]];
[acl setReadAccess:YES forUser:[PFUser currentUser]];
[acl setReadAccess:YES forRoleWithName:@"managers"];
[acl setWriteAccess:YES forRoleWithName:@"managers"];

[privateData setACL:acl];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM