packages/udaru-core/lib/ops/organizationOps.js
function insertOrgAdminUser (job, next) {
    if (job.user) {
      const { id, name } = job.user
      const { id: organizationId } = job.organization

      userOps.insertUser(job.client, { id, name, organizationId }, (err, res) => {
        if (err) return next(err)
        job.user.id = res.rows[0].id

        userOps.insertPolicies(job.client, job.user.id, [{id: job.adminPolicyId, variables: {}}], utils.boomErrorWrapper(next))
      })

      return
    }

    next()
  }
function insertOrgAdminUser (job, next) {
    if (job.user) {
      const { id, name } = job.user
      const { id: organizationId } = job.organization

      userOps.insertUser(job.client, { id, name, organizationId }, (err, res) => {
        if (err) return next(err)
        job.user.id = res.rows[0].id

        userOps.insertPolicies(job.client, job.user.id, [{id: job.adminPolicyId, variables: {}}], utils.boomErrorWrapper(next))
      })

      return
    }

    next()
  }
function insertOrgAdminUser ( job , next ) { if ( job . user ) { const { id , name } = job . user const { id : organizationId } = job . organization userOps . insertUser ( job . client , { id , name , organizationId } , ( err , res ) => { if ( err ) return next ( err ) job . user . id = res . rows [ 0 ] . id userOps . insertPolicies ( job . client , job . user . id , [ { id : job . adminPolicyId , variables : { } } ] , utils . boomErrorWrapper ( next ) ) } ) return } next ( ) }
Insert a new user and attach to it the organization admin policy

@param  {Object}   job
@param  {Function} next
Insert a new user and attach to it the organization admin policy