diff options
Diffstat (limited to 'src/couchdb/couch_js_functions.hrl')
-rw-r--r-- | src/couchdb/couch_js_functions.hrl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/couchdb/couch_js_functions.hrl b/src/couchdb/couch_js_functions.hrl index a2a40b3c..67f06686 100644 --- a/src/couchdb/couch_js_functions.hrl +++ b/src/couchdb/couch_js_functions.hrl @@ -99,14 +99,18 @@ -define(REP_DB_DOC_VALIDATE_FUN, <<" function(newDoc, oldDoc, userCtx) { - if (newDoc.user_ctx) { + function reportError(error_msg) { + log('Error writing document `' + newDoc._id + + '` to replicator DB: ' + error_msg); + throw({forbidden: error_msg}); + } - function reportError(error_msg) { - log('Error writing document ' + newDoc._id + - ' to replicator DB: ' + error_msg); - throw({forbidden: error_msg}); - } + var isReplicator = (userCtx.roles.indexOf('_replicator') >= 0); + if (oldDoc && !newDoc._deleted && !isReplicator) { + reportError('Only the replicator can edit replication documents.'); + } + if (newDoc.user_ctx) { var user_ctx = newDoc.user_ctx; if (typeof user_ctx !== 'object') { |