Skip to content
Snippets Groups Projects
Commit 6566b819 authored by Henrique Varella Ehrenfried's avatar Henrique Varella Ehrenfried
Browse files

Start to make ACL to work

parent 20e521f4
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,31 @@ ...@@ -27,6 +27,31 @@
"foreignKey": "id" "foreignKey": "id"
} }
}, },
"acls": [], "acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
},
{
"accessType": "count",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
],
"methods": {} "methods": {}
} }
...@@ -36,6 +36,31 @@ ...@@ -36,6 +36,31 @@
"foreignKey": "id" "foreignKey": "id"
} }
}, },
"acls": [], "acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}
],
"methods": {} "methods": {}
} }
...@@ -17,17 +17,17 @@ ...@@ -17,17 +17,17 @@
}, },
"latitude": { "latitude": {
"type": "number", "type": "number",
"required": true,
"postgresql": { "postgresql": {
"dataType": "float" "dataType": "float"
}, }
"required": true
}, },
"longitude": { "longitude": {
"type": "number", "type": "number",
"required": true,
"postgresql": { "postgresql": {
"dataType": "float" "dataType": "float"
}, }
"required": true
}, },
"android_id": { "android_id": {
"type": "string" "type": "string"
...@@ -56,6 +56,31 @@ ...@@ -56,6 +56,31 @@
"foreignKey": "id" "foreignKey": "id"
} }
}, },
"acls": [], "acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}
],
"methods": {} "methods": {}
} }
...@@ -43,24 +43,32 @@ module.exports = function(app) { ...@@ -43,24 +43,32 @@ module.exports = function(app) {
if (!userId) { if (!userId) {
return reject(); return reject();
} }
else{
console.log("USER ID ::",userId)
}
console.log("ROLE ::", role)
console.log("CONTEXT MODEL ::", context.model)
console.log("CONTEXT ID ::", context.id)
// check if userId is in team table for the given project id // check if userId is in team table for the given project id
context.model.findById(context.modelId, function(err, model) { context.model.findById(userId, function(err, model) {
if (err || !model)
return reject();
var EndUser = app.models.EndUser; app.models.EndUser.findById(userId, function(err2, user){
EndUser.count({ console.log("ERR ::", err)
ownerId: model.ownerId, console.log("ERR 2::", err2)
memberId: userId console.log("MODEL ::", model)
}, function(err, count) {
if (err) {
console.log(err);
return cb(null, false);
}
cb(null, count > 0); // true = is a team member console.log("ENDUSER MODEL", user)
});
if (err || err2 || !user || !model)
return reject();
if(user.permission !== role)
return reject();
else
return cb(null,true)
})
}); });
}); });
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
module.exports = function enableAuthentication(server) { module.exports = function enableAuthentication(server) {
// enable authentication // enable authentication
// server.enableAuth(); server.enableAuth();
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment