I created the view via this method. The view works perfectly… on the admin port. I switch to port 4984, include a SyncGatewaySession cookie… and then all I get is 403 forbidden. (It’s “unauthorized” when the cookie is missing or invalid.)
Last time we discussed that 403 means it’s not in the user’s channel, so I tried adding a channel to the view, but could not do it. All of the documents emitted by the view ARE in the user’s channel but the resulting JSON doesn’t have a channels property. Here is the result of the view from the admin port. The channel I want the view to be in is “new-quote”.
{
"total_rows": 3,
"rows": [
{
"id": "quote1",
"key": "quote1",
"value": "new-quote"
},
{
"id": "quote1042",
"key": "quote1042",
"value": "new-quote"
},
{
"id": "quote3001",
"key": "quote3001",
"value": "new-quote"
}
]
}
Here it is from the public port (with a valid SyncGatewaySession cookie)
{
"error": "Forbidden",
"reason": "forbidden"
}
Here is the view itself:
{
"views":{
"new_quote":{
"map":"function (doc, meta) { if (doc.channels == 'new-quote') emit(meta.id, doc.channels); }"
}
}
}
And here is the curl used to install the view:
curl -vX PUT http://sync.gateway.ip.address:4985/{dbname}/_design/new_quote -H "Content-Type: application/json" -d @view.json
- How do I get access to this view on the public port?
- How do I restrict access to only users of the “new-quote” channel? (Or does a view automatically only emit documents that are in the users’ channels?)
Have a great weekend.
Kind regards,
David