Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

COUCHDB-1511 - User docs require doc.roles

A _users doc must include roles otherwise the user receives an opaque
error. This patch throws an error if it is missing and adds a test to
verify that the user receives a readable error message.
  • Loading branch information...
commit 41205000c7d756a951021641c586b73f7489510a 1 parent 09ead8a
@rnewson rnewson authored
View
10 share/www/script/test/users_db.js
@@ -112,6 +112,16 @@ couchTests.users_db = function(debug) {
}
jchrisUserDoc.roles = [];
+ // "roles" must exist
+ delete jchrisUserDoc.roles;
+ try {
+ usersDb.save(jchrisUserDoc);
+ T(false && "should only allow us to save doc when roles exists");
+ } catch(e) {
+ T(e.reason == "doc.roles must exist");
+ }
+ jchrisUserDoc.roles = [];
+
// character : is not allowed in usernames
var joeUserDoc = CouchDB.prepareUserDoc({
name: "joe:erlang"
View
6 src/couchdb/couch_js_functions.hrl
@@ -31,7 +31,11 @@
throw({forbidden: 'doc.name is required'});
}
- if (newDoc.roles && !isArray(newDoc.roles)) {
+ if (!newDoc.roles) {
+ throw({forbidden: 'doc.roles must exist'});
+ }
+
+ if (!isArray(newDoc.roles)) {
throw({forbidden: 'doc.roles must be an array'});
}
Please sign in to comment.
Something went wrong with that request. Please try again.