incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Shorin <kxe...@gmail.com>
Subject Re: commonjs in validation docs
Date Mon, 03 Jun 2013 08:12:40 GMT
On Mon, Jun 3, 2013 at 11:50 AM, Stephen Bartell <snbartell@gmail.com> wrote:
> So then am I out of luck when it comes to requires in my validation docs?

Why so? I'd a bit modified the example to remove views confusion:

{
   "_id": "_design/test",
   "lib": {
       "security": "function user(userctx, secobj){\n  return {\n
is_admin: function(){ return userctx.roles.indexOf('_admin') !== -1 }
  \n  }  \n}\nexports.user = user;"
   },
   "validate_doc_update": "function(newdoc, olddoc, userctx, secobj)
{\n  user = require('lib/security').user(userctx, secobj);\n  if
(!user.is_admin()) { throw({forbidden: '_admin role required'}) };\n}"
}

I believe the docs example is needed to be completely rewritted.


--
,,,^..^,,,

Mime
View raw message