summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-07-13 14:30:38 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-07-13 14:30:38 +0000
commit00cf3df200a49b9d00abf914b5691de1cc10ba6a (patch)
tree31d9f006c7fcb7222c9f493d8c252abff9a951b3
parentfa69901d71d62af68f1e47f89e1a5d5079a7d151 (diff)
test and fix for deleting users documents
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@963731 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/test/users_db.js7
-rw-r--r--src/couchdb/couch_js_functions.hrl8
2 files changed, 10 insertions, 5 deletions
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index b85adf08..667ff3c1 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -85,8 +85,13 @@ couchTests.users_db = function(debug) {
T(/conflict/.test(e.reason))
}
+ // you can delete a user doc
+ s = CouchDB.session().userCtx;
+ T(s.name == null);
+ T(s.roles.indexOf("_admin") !== -1);
+ T(usersDb.deleteDoc(jchrisWithConflict).ok);
};
-
+
usersDb.deleteDb();
run_on_modified_server(
[{section: "couch_httpd_auth",
diff --git a/src/couchdb/couch_js_functions.hrl b/src/couchdb/couch_js_functions.hrl
index 3214b1f6..1f314f6e 100644
--- a/src/couchdb/couch_js_functions.hrl
+++ b/src/couchdb/couch_js_functions.hrl
@@ -12,10 +12,6 @@
-define(AUTH_DB_DOC_VALIDATE_FUNCTION, <<"
function(newDoc, oldDoc, userCtx) {
- if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
- throw({forbidden : 'doc.type must be user'});
- } // we only allow user docs for now
-
if (newDoc._deleted === true) {
// allow deletes by admins and matching users
// without checking the other fields
@@ -27,6 +23,10 @@
}
}
+ if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
+ throw({forbidden : 'doc.type must be user'});
+ } // we only allow user docs for now
+
if (!newDoc.name) {
throw({forbidden: 'doc.name is required'});
}