feat: 🎸 roles
This commit is contained in:
1 parent
b652f759c8
commit
fc4dab606e
10 files changed
+183
-23
No files matched your search
@@ -29,7 +29,8 @@ export default class CollectionAbility extends Ability {
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasAuthorizedCollectionAction(action) {
|
||||
const { authorized_collection_actions } = this.model;
|
||||
const authorized_collection_actions =
|
||||
(this.model || {}).authorized_collection_actions || {};
|
||||
const collection = this.collection || {};
|
||||
return authorized_collection_actions[collection]?.includes(action);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ export default class BaseModel extends Model {
|
||||
})
|
||||
authorized_actions;
|
||||
|
||||
@attr({
|
||||
readOnly: true,
|
||||
})
|
||||
authorized_collection_actions;
|
||||
|
||||
set scopeModel(model) {
|
||||
if (model) {
|
||||
const json = model.serialize();
|
||||
|
||||
@@ -4,6 +4,12 @@ import { trait } from 'ember-cli-mirage';
|
||||
export default factory.extend({
|
||||
type: 'global',
|
||||
|
||||
authorized_collection_actions: () => {
|
||||
return {
|
||||
roles: ['create', 'list'],
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates realistic-ish IDs while still being deterministic.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user