authorized icon indicating copy to clipboard operation
authorized copied to clipboard

can you provide simple example

Open mylastore opened this issue 8 years ago • 2 comments
trafficstars

Example route /admin how to prevent a normal user or authorize but not admin to access that route? Sorry I am new to nodejs and express.

mylastore avatar Oct 10 '17 21:10 mylastore

auth.role('admin', (req, done) => {
    done(null, getUser(req).type === 'admin');
  });
...
auth.action('administer', ['admin', 'editorz']);
...
app.get(
    '/somePath', 
    auth.can('administer'),
    (req, res, next) => {})

malixsys avatar Feb 19 '18 07:02 malixsys

The project ships with a test suite which shows some examples.

markstos avatar Mar 31 '21 16:03 markstos