Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User.create({
- username: 'admin',
- email: 'admin@admin.com',
- password: 'password',
- active: true
- }, function (err, user) {
- Role.create({
- name: 'Admin'
- }, function (err, role) {
- if (err) throw err;
- console.log('Created role:', role);
- //make user an admin
- role.principals.create({
- principalType: RoleMapping.USER,
- //principalType: RoleMapping.ROLE,
- principalId: user.id,
- active: true
- }, function (err, principal) {
- if (err) throw err;
- console.log('Principal:', principal);
- });
- });
- });
- "name": "Customer",
- "base": "PersistedModel",
- "strict": false,
- "idInjection": false,
- "options": {
- "validateUpsert": true
- },
- "properties": {
- "name": {
- "type": "string",
- "required": true
- },
- "description": {
- "type": "string"
- },
- "active": {
- "type": "boolean"
- }
- },
- "validations": [],
- "relations": {
- "products": {
- .........
- },
- "users": {
- .........
- }
- },
- "acls": [
- {
- "accessType": "*",
- "principalType": "ROLE",
- "principalId": "$everyone",
- "permission": "DENY"
- },
- {
- WORKS AS EXPECTED
- "accessType": "*",
- "principalType": "ROLE",
- "principalId": "$authenticated",
- "permission": "ALLOW"
- },
- {
- RETURNS 401 AFTER LOGGING IN AS USER ASSIGNED TO ROLE
- "accessType": "*",
- "principalType": "ROLE",
- "principalId": "Admin",
- "permission": "ALLOW"
- }
- ],
- "methods": []
- "_id" : ObjectId("55b7c34d6033a33758038c3b"),
- "username" : "admin",
- "password" : ....,
- "email" : "admin@admin.com",
- "active" : true
- "_id" : ObjectId("55b7c34d6033a33758038c3e"),
- "name" : "Admin",
- "created" : ISODate("2015-07-28T18:00:45.336Z"),
- "modified" : ISODate("2015-07-28T18:00:45.336Z")
- "_id" : ObjectId("55b7c34d6033a33758038c41"),
- "principalType" : "USER",
- "principalId" : "55b7c34d6033a33758038c3b",
- "roleId" : ObjectId("55b7c34d6033a33758038c3e"),
- "active" : true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement