-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsync_gateway_config.json
executable file
·91 lines (79 loc) · 3.24 KB
/
sync_gateway_config.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
"log": [
"CRUD+",
"REST+",
"Changes+",
"Attach+"
],
"databases": {
"couchbase-connect": {
"server": "http://localhost:8091",
"sync":
`
function(doc, oldDoc){
log("processing " + doc._id);
if (doc.type == "contact") {
// Users can't assign their contact document to another user.
if (oldDoc != null && oldDoc.userId != doc.userId) throw({forbidden: "Can't change userId."});
// Users can only change their own contact.
requireUser(oldDoc == null ? doc.userId : oldDoc.userId);
} else if (doc.type == "contactexchange") {
// Can't modify a contact exchange document.
if (oldDoc != null) throw({forbidden: "Can't modify a contact exchange document."});
// Issuing user must be the local user.
requireUser(doc.localUserId);
} else if (doc.type == "surveyresult") {
// Can't modify a conference survey document.
if (oldDoc != null) throw({forbidden: "Can't modify a conference survey document."});
// Extract the userId from the document _id (the format of _id is "surveyresult-USER-ID").
var userId = doc._id.substring(13);
// Users can only create their own conference survey.
requireUser(userId);
} else if (doc.type == "ratingresult") {
// Extract the userId from the document _id (the format of _id is "sessionrating-session-XXXX-USER-ID").
var userId = doc._id.substring(27);
// Users can only change their own session ratings.
requireUser(userId);
} else if (doc.type == "scavengerhuntcapture") {
// Extract the userId from the document _id (the format of _id is "scavenger-hunt-item-XXX-USER-ID").
var userId = doc._id.substring(24);
// Users can only change their own scavenger hunt pictures.
requireUser(userId);
} else if (doc.type == "agenda") {
// Extract the userId from the document _id (the format of _id is "agenda-USER-ID").
var userId = doc._id.substring(7);
// Users can only change their own agenda.
requireUser(userId);
} else {
// The 'admin' user can change any document.
requireUser("admin");
}
if (doc.type == "contact") {
// give user access to it's contact channel
access(doc.userId, "contact-" + doc.userId);
// add doc to user's contact channel
channel("contact-" + doc.userId);
}
if (doc.type == "contactexchange") {
// trade access to each user's contact channel
access(doc.userId, "contact-" + doc.localUserId);
access(doc.localUserId, "contact-" + doc.userId);
}
if (doc.type == "session" ||
doc.type == "speaker" ||
doc.type == "schedule" ||
doc.type == "appconfig" ||
doc.type == "scavengerhuntitem" ) {
// everyone can sync these documents
channel("public")
}
}
`,
"users": {
"GUEST": {
"disabled": true
}
}
}
}
}