How to approve uploads to CloudKit

131 views Asked by At

When creating an application that uses CloudKit, sometimes you allow the user to create and upload data to the public database which will be publicly available to everyone once it's created. This leads to my question which is:

How do you review/moderate/approve user created data before making it available to the world?

1

There are 1 answers

0
karbonator On BEST ANSWER

There are two main ways in which you can accomplish this:

  1. Have a separate record type for non-approved content which you allow any authenticated user to create records in (you can control this with the roles security settings on the record type). Then, once you approve the content, copy the content over to a record type that only you have the role to edit records with (either programmatically through some admin app you have or the CloudKit Dashboard). The record type you copy the record to should be the record type that your app is using to show content to other users.

  2. Allow authenticated users (again, through the roles security setting) to create records directly in the record type, but only show the content from the record type if a certain flag is set (for instance, add an "isApproved" field). The main caveat to this approach is that there is no way you can guarantee that the user does not write with the "isApproved" field set to true. Also, if you go this way, make sure to not let authenticated users write (only "create") to ensure they can't edit other users content.