Assigning a document to a channel on the fly

31 views
Skip to first unread message

Florion COIFFÉ

unread,
Jun 8, 2015, 10:07:06 AM6/8/15
to mobile-c...@googlegroups.com
I want to give all documents access to a specific channel. But I get 403 while pushing error telling me I don't have access to a channel.
Is it possible to give an access on the fly and do a require just after ? (Like the following.-)

access("oliver", "mobileFor");
requireAccess("mobileFor");


I made it work by removing the requireAccess("mobileFor"), and after syncing, I stop the Gateway, I add back the requireAccess("mobileFor") and start again the Gateway.
After that change, the sync goes well. It is weird because that means I can't create document when the user is new.

Thanks :)

My code is actually like this:
channel("mobileFor");
access(doc.owner, "mobileFor");
requireUser(doc.owner);
requireAccess("mobileFor");

Jens Alfke

unread,
Jun 8, 2015, 1:01:40 PM6/8/15
to mobile-c...@googlegroups.com

On Jun 8, 2015, at 7:07 AM, Florion COIFFÉ <cflo...@gmail.com> wrote:

I want to give all documents access to a specific channel. But I get 403 while pushing error telling me I don't have access to a channel.

It’s users that have to be given access to channels; documents are put in channels.
If you want to put all docs into a particular channel, just call channel(“thatChannel”) in the sync function.
If you want to give all users access to a channel, it’s easiest to add it to the admin_channels array when you create the user account.

access("oliver", "mobileFor");
requireAccess("mobileFor");

That’s an interesting case — it currently doesn't work, because the requireAccess() function checks the existing access, not the modifications made by access() calls. But it makes sense to have it behave the way you want — you could file an issue to get that changed.

—Jens
Reply all
Reply to author
Forward
0 new messages