requireUser not working for me.

I authenticate using persona and I see a message in the sync gateway logs that confirms I’m authenticated as user bsg2@gmx.com

When my sync function reads like this (with requireUser commented out):
"sync": `function(doc, oldDoc) {
channel(doc.channels);
if (doc.type == "user") {
channel("profiles");
// requireUser(["Admin", "bsg2@gmx.com"]);
}
}`

I can get updates on documents of type user. (I notice in the logs it says "as Admin".)

However, when I uncomment the requireUser line and I'm logged in via persona as bsg2@gmx.com I do not get synchronization updates. Can anyone explain why this is?
Thank you

1 Answer

« Back to question.

Hello bmhardy,

Know it has been awhile and wondering if you resolved the issue?

Believe when you comment out the requireUser(...) method, it is only local and single user to the client you are accessing.
When requireUser(...) is uncommented while logged in as "bsg2@gmx.com", the other user that is required, "Admin" in your case, is not logged in and probably that is why you do not get synchronization updates.

Are you able to validate when both "Admin" and "bsg2@gmx.com" simultaneously logged on as both are required users in your case? Any error logs you get?

If you removed the "Admin" entry while being logged in as the other username in the list, are you able to get any updates on the document(s)?

Cheers,
William