All files / utils packAccess.js

100% Statements 8/8
100% Branches 4/4
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22            10x 10x               28x 13x 10x     10x  
/**
 * Who may do what with a pack, beyond a permission check.
 *
 * @implements UC-STORE-007.1
 */
 
const { permissionChecker } = require('./PermissionChecker')
const { isPlatformAdminUser } = require('./platformAdmin')
 
/**
 * The author, the owner of the pack's flow, or a platform admin (the takedown
 * path until a Report button exists). The same people manage the pack: its
 * comments, who may comment, whether comments are on.
 */
async function canDeletePack(docClient, pack, userId) {
  if (pack.authorId === userId) return true
  if (await permissionChecker.isOwner(userId, pack.flowId)) return true
  return isPlatformAdminUser(docClient, userId)
}
 
module.exports = { canDeletePack }