Guest User

Untitled

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