private void updateReplicators(Authenticator authenticator) {
Database database = getDatabase(databaseName);
String cookie = CookieManager.getInstance().getCookie(syncUrl.toExternalForm());
boolean shouldUseCookies = !(authenticator instanceof BasicAuthenticator);
if (shouldUseCookies && cookie == null) {
Log.d(TAG, "Using cookie based authentication however no cookies have been set for key "+ syncUrl.toExternalForm());
}
List<Replication> replications = getAllReplications(database);
if (replications != null) {
for (Replication replication : replications) {
if (shouldUseCookies) {
String type = replication.isPull() ? "pull" : "push";
Log.d(TAG, "Putting cookie into replicator of type "+ type +" cookie = "+ cookie);
replication.getHeaders().put("Cookie", cookie);
} else {
replication.deleteCookie(syncUrl.toExternalForm());
replication.getHeaders().put("Cookie", null);
CookieManager.getInstance().setCookie(syncUrl.toExternalForm(), null);
}
replication.setAuthenticator(authenticator);
replication.stop();
}
}
}
Here is my config.json - updated to simply check for userid of "brianh"
{
"interface": ":4984",
"adminInterface": ":4985",
"log": ["CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Shadow", "Shadow+", "Changes", "Changes+"],
"databases": {
"bsg_sync": {
"server": "http://localhost:8091",
"bucket": "bsg_sync",
"users": {
"GUEST": {"disabled": false, "admin_channels":["*"], "all_channels":["*"]}
},
"sync": `function(doc, oldDoc) {
channel(doc.channels);
if (doc.type == "profile") {
if (oldDoc) {
requireUser("brianh");
}
}
}`
}
}
}
Here's the data on the server
curl -X GET localhost:4985/bsg_sync/brianh
{"_id":"brianh","_rev":"297-51800495-1cfc-412e-88cd-e456803c7e34","mySchedule":["session:6696","session:6232","session:6370","session:5058","session:5314"],"type":"profile"}
Another item should be added to the list here but is not.
replication.setCookie("SyncGatewaySession", value, null, null, false, false);
I was trying to set the name of the cookie to the same value I used in the CookieManager and then set the value to the full cookie string. I thought that might be the problem. My pull replicator continues to work them but I have the push sync problem I originally wrote about so I assume the name should be "SyncGatewaySession" and the value should the the value from the SyncGatewaySession name value pair in the cookie. Any advice?Thanks
--To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/1d41107b-38c3-4d6c-a9b4-ee3526740b31%40googlegroups.com.
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 mobile-couchba...@googlegroups.com.