Skip to content

Commit

Permalink
adding conditional for email permission logic
Browse files Browse the repository at this point in the history
  • Loading branch information
stoopidJSON committed Feb 26, 2021
1 parent 850a5a5 commit 69815c0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/models/entity-contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ const entityContact = (sequelize, DataTypes) => {
const contact = await models.Contact.findById(ec.contactId)
const e = await utils.loadCasbin()

for (const email of contact.email) {
const p = [email.address, `/entity/${ec.entityId}`, '(GET)|(POST)']
await e.addPolicy(...p)
if (typeof contact.email !== 'undefined' && contact.email.length > 0) {
for (const email of contact.email) {
const p = [email.address, `/entity/${ec.entityId}`, '(GET)|(POST)']
await e.addPolicy(...p)
}
}
}

Expand Down

0 comments on commit 69815c0

Please sign in to comment.