Skip to content

Commit

Permalink
dbCtx.admins is not always defined
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 1, 2011
1 parent fe36c01 commit 8b717de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions registry/app.js
Expand Up @@ -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
}
Expand Down

0 comments on commit 8b717de

Please sign in to comment.