-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandre Marcondes
committed
Feb 24, 2018
1 parent
821a1a4
commit 732f09b
Showing
92 changed files
with
680 additions
and
2,708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
Visitor: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* globals User */ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false], ['index', true]], | ||
CollectiveManager: [ | ||
['index', true], | ||
[ | ||
'create', | ||
'delete', | ||
req => | ||
User.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: req.post.collectiveId, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}), | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* globals User */ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false], ['index', true]], | ||
CollectiveManager: [ | ||
['index', true], | ||
[ | ||
'create', | ||
'delete', | ||
req => | ||
User.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: req.post.collectiveId, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}), | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* globals Admin */ | ||
module.exports = { | ||
Visitor: [['new', 'create', 'edit', 'update', 'activate', 'deactivate', false]], | ||
User: [['new', 'create', 'edit', 'update', 'activate', 'deactivate', false]], | ||
CollectiveManager: [ | ||
['new', 'create', true], | ||
[ | ||
'edit', | ||
'update', | ||
'activate', | ||
'deactivate', | ||
req => { | ||
Admin.Campaign.query() | ||
.where('id', req.params.id) | ||
.then(([campaign]) => | ||
Admin.Campaign.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: campaign.collectiveId, | ||
user_id: req.user.id, | ||
}), | ||
) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
}, | ||
], | ||
], | ||
Admin: [['new', 'create', 'edit', 'update', 'activate', 'deactivate', true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* globals User */ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false]], | ||
CollectiveManager: [ | ||
['index', true], | ||
[ | ||
'show', | ||
'edit', | ||
'update', | ||
req => | ||
User.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: req.params.id, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}), | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* globals User */ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false]], | ||
CollectiveManager: [ | ||
['index', true], | ||
[ | ||
'show', | ||
'edit', | ||
'update', | ||
req => | ||
User.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: req.params.id, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}), | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false]], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
Visitor: [[false]], | ||
User: [[false]], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* globals User, CollectiveAdmins */ | ||
module.exports = { | ||
Visitor: [[false], ['index', true]], | ||
User: [['index', true]], | ||
CollectiveManager: [ | ||
['create', 'index', true], | ||
[ | ||
'edit', | ||
'update', | ||
'delete', | ||
req => | ||
CollectiveAdmins.query() | ||
.where({ | ||
collective_id: req.params.collectiveId, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => results.length > 0), | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* global Campaign */ | ||
|
||
const isPublicCampaign = req => | ||
Campaign.query() | ||
.where('id', req.params.id) | ||
.then(([result]) => result.published); | ||
|
||
module.exports = { | ||
Visitor: [['show', isPublicCampaign], ['join', false]], | ||
User: [['show', 'join', isPublicCampaign]], | ||
CollectiveManager: [['show', 'join', true]], | ||
Admin: [['show', 'join', true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* globals CollectiveBans */ | ||
module.exports = { | ||
Visitor: [['join', false], ['index', 'show', true]], | ||
User: [ | ||
['index', true], | ||
// Users are already blocked from the passport middleware | ||
['join', true], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
Visitor: [['index', false]], | ||
User: [['index', true]], | ||
Admin: [['index', true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
Visitor: [['index', true], ['show', false]], | ||
User: [['index', true], ['show', true]], | ||
Admin: [['index', true], ['show', true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
Visitor: [ | ||
[false], | ||
[ | ||
'show', | ||
'updateDisputeData', | ||
'updateSubmission', | ||
'addAttachment', | ||
'download', | ||
'setSignature', | ||
'removeAttachment', | ||
false, | ||
], | ||
], | ||
User: [ | ||
['index', 'create', true], | ||
[ | ||
'show', | ||
'edit', | ||
'update', | ||
'destroy', | ||
'updateSubmission', | ||
'updateDisputeData', | ||
'addAttachment', | ||
'download', | ||
'setSignature', | ||
'removeAttachment', | ||
req => req.dispute.userId === req.user.id, | ||
], | ||
], | ||
Admin: [['download', true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
Visitor: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* globals User */ | ||
module.exports = { | ||
Visitor: [[false], ['createComment', false], ['index', true]], | ||
User: [ | ||
['create', 'createComment', 'votePoll', 'index', true], | ||
[ | ||
'edit', | ||
'update', | ||
'delete', | ||
req => { | ||
if (req.post.userId !== req.user.id) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}, | ||
], | ||
], | ||
CollectiveManager: [ | ||
['create', 'index', 'createComment', true], | ||
[ | ||
'edit', | ||
'update', | ||
'delete', | ||
req => { | ||
if (req.user.role === 'Admin') { | ||
return true; | ||
} | ||
|
||
return User.knex() | ||
.table('Campaigns') | ||
.select('collective_id') | ||
.where('id', req.params.campaign_id) | ||
.then(([result]) => | ||
User.knex() | ||
.table('CollectiveAdmins') | ||
.where({ | ||
collective_id: result.collective_id, | ||
user_id: req.user.id, | ||
}) | ||
.then(results => { | ||
if (results.length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}) | ||
.catch(() => false), | ||
); | ||
}, | ||
], | ||
], | ||
Admin: [['createComment', true], [true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
Visitor: [ | ||
[ | ||
'new', | ||
'create', | ||
'destroy', | ||
'showEmailForm', | ||
'sendResetEmail', | ||
'showPasswordForm', | ||
'resetPassword', | ||
true, | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* globals Account */ | ||
|
||
module.exports = { | ||
Visitor: [[false], ['activation', 'activate', 'create', 'new', true]], | ||
User: [ | ||
[false], | ||
['activation', true], | ||
['edit', 'update', req => req.params.id === req.user.id], | ||
[ | ||
'show', | ||
req => { | ||
if (req.params.id === req.user.id) { | ||
return true; | ||
} | ||
|
||
return Account.query() | ||
.where({ user_id: req.params.id }) | ||
.limit(1) | ||
.then(([account]) => !account.private); | ||
}, | ||
], | ||
], | ||
Admin: [[true]], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Roles */ | ||
|
||
module.exports = ['Visitor.User.CollectiveManager.Admin']; |
Oops, something went wrong.