Thanks for these questions. I think there are a few issues we have to 
resolve.

On Thursday, January 1, 2015 at 7:59:44 PM UTC-8, vf wrote:
>
> So I haven't retested Issue #2, but I was able to resolve Issue #1 by 
> hitting POST /_resync on the admin port.
>
> It's not very obvious that that is a required step after changing the sync 
> function in a way that alters permissions. For example, it's not mentioned 
> in the Sync Function API documentation at all (
> http://developer.couchbase.com/mobile/develop/guides/sync-gateway/sync-function-api-guide/index.html).
>  
> I notice now that when I change the sync function and restart the server 
> that there's a little blurb outputted into the error log. I'm assuming you 
> don't automatically resync on launch because of the performance 
> implications?
>
>
The admin sync function updates are not persisted, when you are done 
developing you need to update your config files.
 

> On a related note, when one changes the sync function using the Admin UI, 
> is it correct to assume that the new sync function is used while the server 
> is running and that the server reverts back to the sync function given in 
> config.json upon restart? Is it necessary to hit POST /_resync after 
> changing the sync function in the Admin UI?
>

I'm not sure about _resync maybe Adam or Jens can answer. It might be that 
we just need to call resync after we save the sync function (in the admin 
console code).

Chris
 

>
> On Thursday, January 1, 2015 5:38:48 PM UTC-5, vf wrote:
>>
>> Oh, I'm running SG 1.0.4. (I had the same issue with 1.0.3)
>>
>> On Thursday, January 1, 2015 5:03:05 PM UTC-5, vf wrote:
>>>
>>> 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/a3a47656-153d-40ba-ad9a-aeaf74334fdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to