Skip to content

Commit

Permalink
fix: Always create the template roles and state machine permissions
Browse files Browse the repository at this point in the history
Previously we were recording if these had been created. However, this caused problems if state
machine restrictions were manually removed, or changed between builds. Now, create regardless
because that seems like the expected behaviour.
  • Loading branch information
jezhiggins committed Nov 30, 2018
1 parent 82e877a commit da9857a
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions lib/components/services/rbac/admin/apply-default-blueprint-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ function gatherStateMachineRestrictions (stateMachines, permissionModel) {
return docTasks
} // gatherStateMachineRestrictions

async function collectKnownDocs (blueprintDocs) {
const knownDocs = {}
const domains = ['templateRole', 'roleGrant', 'stateMachineRestriction', 'roleMembership']
for (const domain of domains) {
const docIds = await blueprintDocs.getDomainDocIds(domain)
knownDocs[domain] = docIds
}
return knownDocs
} // collectKnownDocs

module.exports = async function applyBlueprintDocs (
blueprintDocs,
blueprintComponents,
Expand All @@ -124,16 +114,8 @@ module.exports = async function applyBlueprintDocs (
)

const docTasks = [...roleTemplateTasks, ...restrictionTasks]
const knownDocs = await collectKnownDocs(blueprintDocs)

// the known docIds, grouped by domain, and all
// docs required from the blueprints... so for all unknown docs, go make them.
for (const task of docTasks) {
if (knownDocs[task.domain].indexOf(task.docId) === -1) {
// Unknown!
const doc = task.docMaker(task.docId, task.docSource)
await task.dao.create(doc, {})
await blueprintDocs.registerDocument(task.domain, task.docId)
}
const doc = task.docMaker(task.docId, task.docSource)
await task.dao.upsert(doc, {})
}
}

0 comments on commit da9857a

Please sign in to comment.