node_acl icon indicating copy to clipboard operation
node_acl copied to clipboard

looking for example

Open kcnkumar opened this issue 9 years ago • 5 comments

Hi

I am using Node, Express and mongo. can anyone give an example how to use ACL in DEMO App and please explain steps how to use ACL in same...

ThanX..

kcnkumar avatar Feb 02 '16 12:02 kcnkumar

The same problem...

ghost avatar Feb 16 '16 14:02 ghost

hey @jaider2523
if you tried anything or if you referring any portals/sites just share the same,let me try the same

Regards Nishanth Skype ID: nishanthrajsh

kcnkumar avatar Feb 16 '16 16:02 kcnkumar

@kcnkumar

Any solution....?,

ghost avatar Feb 28 '16 16:02 ghost

i kept that on hold man and this is my try where i can take page to 500/access denied

in model/user.js

User.add({ name: { type: Types.Name, required: true, index: true }, email: { type: Types.Email, initial: true, required: true, index: true }, password: { type: Types.Password, initial: true, required: true } }, 'Permissions', { isAdmin: { type: Boolean, label: 'Can access Keystone', index: true }, role: { type: Types.Select, options: 'superuser, public, guest', initial: true, required: true } });

and in routes/index.js

initialize var mongoose = require('mongoose'); var acl = require('acl'); var dbc = mongoose.createConnection('mongodb://127.0.0.1:27017/my-site', {});

acl.addUserRoles("superuser","user",cb); app.get('/contact', acl.middleware(2, 'fflender', 'read'), routes.views.contact);

here when you switch to contact it shows 500/access denied

if you tried with different please share and if any one else know about #167 please guide us!!!!

kcnkumar avatar Feb 28 '16 18:02 kcnkumar

A really good example was given by @icompuiz found in the examples right here: https://github.com/OptimalBits/node_acl/issues/38

It definitely helped to understand things quite a bit in terms of the acl side of things whilst making slight customisations to meanjs (which I am more familiar).

It's possible but I'd have to ask to know for sure, that meanjs code is an evolution of code within the above linked issue which predates the addition of the acl within meanjs:

Loading all the acls is done here and examples of useage are:

Both address acl's use of req.userId vs mongo's:req.user._id**. I would recommend both as nice examples of acl use in conjunction with Mongo, Node and Express.

** There has since been and update which patches these differences, however the last I checked the published version 0.4.9 doesn't include the lines that make the change. To get the version of 0.4.9 with the update you can install from github via: npm install optimalbits/node_acl.

Wuntenn avatar Sep 13 '16 20:09 Wuntenn