Permalink
Browse files

dbCtx.admins is not always defined

  • Loading branch information...
1 parent fe36c01 commit 8b717de1888fcfffe20f9344957dac7fe50ca919 @isaacs isaacs committed Sep 1, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 registry/app.js
View
@@ -1183,9 +1183,14 @@ ddoc.validate_doc_update = function (newDoc, oldDoc, user, dbCtx) {
return false
}
function isAdmin () {
- if (dbCtx.admins.names.indexOf(user.name) !== -1) return true
- for (var i=0;i<user.roles.length;i++) {
- if (dbCtx.admins.roles.indexOf(user.roles[i]) !== -1) return true
+ if (dbCtx &&
+ dbCtx.admins) {
+ if (dbCtx.admins.names &&
+ dbCtx.admins.roles &&
+ dbCtx.admins.names.indexOf(user.name) !== -1) return true
+ for (var i=0;i<user.roles.length;i++) {
+ if (dbCtx.admins.roles.indexOf(user.roles[i]) !== -1) return true
+ }
}
return user.roles.indexOf("_admin") >= 0
}

0 comments on commit 8b717de

Please sign in to comment.