couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r963723 - in /couchdb/trunk: share/www/script/test/users_db.js src/couchdb/couch_js_functions.hrl
Date Tue, 13 Jul 2010 14:25:04 GMT
Author: jchris
Date: Tue Jul 13 14:25:03 2010
New Revision: 963723

URL: http://svn.apache.org/viewvc?rev=963723&view=rev
Log:
test and fix for deleting users documents

Modified:
    couchdb/trunk/share/www/script/test/users_db.js
    couchdb/trunk/src/couchdb/couch_js_functions.hrl

Modified: couchdb/trunk/share/www/script/test/users_db.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/users_db.js?rev=963723&r1=963722&r2=963723&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/users_db.js (original)
+++ couchdb/trunk/share/www/script/test/users_db.js Tue Jul 13 14:25:03 2010
@@ -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",

Modified: couchdb/trunk/src/couchdb/couch_js_functions.hrl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_js_functions.hrl?rev=963723&r1=963722&r2=963723&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_js_functions.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_js_functions.hrl Tue Jul 13 14:25:03 2010
@@ -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'});
         }



Mime
View raw message