I’m setting up Sync Gateway and running into two major issues with my sync
function, which I’ll paste here for reference:
function (doc, oldDoc) {
if (doc._deleted) {
return; //temporary.
}
if (!doc.type)
throw({forbidden: 'All documents must have a type'});
if (doc.type === 'organization') {
// requireAccess(doc._id);
if (doc.members) access(doc.members, doc._id);
channel(doc._id);
}
if (doc.type === 'list' || doc.type === 'item') {
// requireAccess(doc.organization);
channel(doc.organization);
}
}
The first and most pressing is that users don’t appear to be assigned
channels correctly. I have an Organization document that has a members
property that contains SG usernames. The sync function I wrote grants
access to a channel define by the organization’s ID.
if (doc.type === 'organization') {
if (doc.members) access(doc.members, doc._id);
channel(doc._id);
}
When I view the organization document from within the SG Admin UI, I can
see that it grants access to user X, but when I view that user I don’t see
the organization’s channel listed.
What’s most frustrating is that this happens inconsistently. In my test
database, I have 3 organizations that user X is a member of, but the user
only has access to 1 channel.
Issue #2 is that I have a user who has access to channel “*”, which I
assumed meant that they had access to every channel. But when I add
requireAccess calls to my sync function, that user can no longer see any
data.
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/60bf7c95-8f0f-4316-89b9-cb900101272a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.