Sync gateway's sync function, requireRole() doesn't seem to work.

38 views
Skip to first unread message

Jason Van

unread,
Aug 6, 2014, 12:14:18 PM8/6/14
to mobile-c...@googlegroups.com
Hey,

I've been able to use requireAccess() and requireUser() in my sync function and they both seem to be working fine. However, I can't seem to get requireRole() to work.

In the sync function I use requireRole("admin") but it always spits back forbidden missing role. My sync gateway cookie gets sent along with the call, and if I do all_docs I see all my docs.

I used the admin port to see what roles the my user has (curl -X GET localhost:4985/todos/_user/:user_id) and the role is there as a part of the admin roles ("admin_roles":["admin"]).

I also checked to see if the role exists (curl -X GET localhost:4985/todos/_role/) and it does (this gets returned ["admin"]).

I'm not sure what I am doing wrong. Is there a specific way of how requireRole() is suppose to work?

Thanks!

Jason

Jens Alfke

unread,
Aug 6, 2014, 1:19:38 PM8/6/14
to mobile-c...@googlegroups.com

On Aug 6, 2014, at 9:14 AM, Jason Van <jason...@gmail.com> wrote:

In the sync function I use requireRole("admin") but it always spits back forbidden missing role. My sync gateway cookie gets sent along with the call, and if I do all_docs I see all my docs.

Sorry, this was a bug in 1.0 (#335). It's been fixed in 1.0.1, so download the new release of Sync Gateway and it should work.

—Jens

Jason Van

unread,
Aug 6, 2014, 10:17:58 PM8/6/14
to mobile-c...@googlegroups.com
Hey Jens,

Thanks for the quick reply, I should have been checking there before posting a question. Will do that in the future.

Anyways, awesome that this is fixed. I'll update my sync gateway tomorrow and fix this up.

Thanks!

Jason
Reply all
Reply to author
Forward
0 new messages