Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. User.create({
  2. username: 'admin',
  3. email: 'admin@admin.com',
  4. password: 'password',
  5. active: true
  6. }, function (err, user) {
  7. Role.create({
  8. name: 'Admin'
  9. }, function (err, role) {
  10. if (err) throw err;
  11.  
  12. console.log('Created role:', role);
  13.  
  14. //make user an admin
  15. role.principals.create({
  16. principalType: RoleMapping.USER,
  17. //principalType: RoleMapping.ROLE,
  18. principalId: user.id,
  19. active: true
  20. }, function (err, principal) {
  21. if (err) throw err;
  22.  
  23. console.log('Principal:', principal);
  24. });
  25. });
  26. });
  27.  
  28. "name": "Customer",
  29. "base": "PersistedModel",
  30. "strict": false,
  31. "idInjection": false,
  32. "options": {
  33. "validateUpsert": true
  34. },
  35. "properties": {
  36. "name": {
  37. "type": "string",
  38. "required": true
  39. },
  40. "description": {
  41. "type": "string"
  42. },
  43. "active": {
  44. "type": "boolean"
  45. }
  46. },
  47. "validations": [],
  48. "relations": {
  49. "products": {
  50. .........
  51. },
  52. "users": {
  53. .........
  54. }
  55. },
  56. "acls": [
  57. {
  58. "accessType": "*",
  59. "principalType": "ROLE",
  60. "principalId": "$everyone",
  61. "permission": "DENY"
  62. },
  63. {
  64. WORKS AS EXPECTED
  65. "accessType": "*",
  66. "principalType": "ROLE",
  67. "principalId": "$authenticated",
  68. "permission": "ALLOW"
  69. },
  70. {
  71. RETURNS 401 AFTER LOGGING IN AS USER ASSIGNED TO ROLE
  72. "accessType": "*",
  73. "principalType": "ROLE",
  74. "principalId": "Admin",
  75. "permission": "ALLOW"
  76. }
  77. ],
  78. "methods": []
  79.  
  80. "_id" : ObjectId("55b7c34d6033a33758038c3b"),
  81. "username" : "admin",
  82. "password" : ....,
  83. "email" : "admin@admin.com",
  84. "active" : true
  85.  
  86. "_id" : ObjectId("55b7c34d6033a33758038c3e"),
  87. "name" : "Admin",
  88. "created" : ISODate("2015-07-28T18:00:45.336Z"),
  89. "modified" : ISODate("2015-07-28T18:00:45.336Z")
  90.  
  91. "_id" : ObjectId("55b7c34d6033a33758038c41"),
  92. "principalType" : "USER",
  93. "principalId" : "55b7c34d6033a33758038c3b",
  94. "roleId" : ObjectId("55b7c34d6033a33758038c3e"),
  95. "active" : true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement