Get user details

@param  {Object}   params { id, organizationId }
@param  {Function} cb
770631
function readUser (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params
      let user

      const tasks = []

      tasks.push((next) => {
        Joi.validate({ id, organizationId }, validationRules.readUser, (err) => {
          if (err) return next(Boom.badRequest(err))
          next()
        })
      })

      tasks.push((next) => {
        const sqlQuery = SQL`
          SELECT id, name, org_id, metadata
          FROM users
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `
        db.query(sqlQuery, (err, result) => {
          if (err) return next(Boom.badImplementation(err))
          if (result.rowCount === 0) return next(Boom.notFound(`User ${id} not found`))

          user = mapping.user(result.rows[0])
          next()
        })
      })

      tasks.push((next) => {
        const sqlQuery = SQL`
          SELECT teams.id, teams.name
          FROM team_members mem, teams
          WHERE mem.user_id = ${id} AND mem.team_id = teams.id
          ORDER BY UPPER(teams.name)
        `
        db.query(sqlQuery, (err, result) => {
          if (err) return next(Boom.badImplementation(err))

          user.teams = result.rows.map(mapping.team.simple)
          next()
        })
      })

      tasks.push((next) => {
        const sqlQuery = SQL`
          SELECT pol.id, pol.name, pol.version, user_pol.variables, user_pol.policy_instance
          FROM user_policies user_pol, policies pol
          WHERE user_pol.user_id = ${id} AND user_pol.policy_id = pol.id
          ORDER BY UPPER(pol.name)
        `
        db.query(sqlQuery, (err, result) => {
          if (err) return next(Boom.badImplementation(err))

          user.policies = result.rows.map(mapping.policy.simple)
          next()
        })
      })

      async.series(tasks, (err) => {
        if (err) return cb(err)

        return cb(null, user)
      })

      return promise
    }
645968
function(params, cb) {
    var correlationId = _cbt.put(offsetResponse(cb));
    var msg = envelope(off.encode()
                          .correlation(correlationId)
                          .client(_options.clientId)
                          .replica()
                          .topic(params.topic)
                          .partition(params.partition)
                          .timestamp()
                          .maxOffsets()
                          .end());
    sendMsg(msg, correlationId, cb);
  }
866256
function(params, callback) {
                var keyId;

                if (params) {
                    if (params.keyId != 'undefined') {
                        keyId = params.keyId;
                    }
                }

                var httpRequestParams = {
                    url: SERVICE_ADDRESSES.SSO_ADDRESS + SERVICES_PATH.SSO_GET_KEY + keyId,
                    method: 'GET',
                    headers: {
                        'Authorization': 'Bearer ' + token
                    }
                };

                httpRequest(httpRequestParams, function(result) {
                    if (!result.hasError) {
                        try {
                            var response = JSON.parse(result.result.responseText);
                        }
                        catch (e) {
                            console.log(e);
                        }

                        callback && callback({
                            hasError: false,
                            secretKey: response.secretKey
                        });
                    }
                    else {
                        callback && callback({
                            hasError: true,
                            code: result.errorCode,
                            message: result.errorMessage
                        });

                        fireEvent('error', {
                            code: result.errorCode,
                            message: result.errorMessage,
                            error: result
                        });
                    }
                });
            }
188102
function (params, state, cb) {
                  state = state || {};

                  if (Card.getCardData) {
                    Card.getCardData(params, state, function (err, viewModel, clientLocals) {
                      cb(err, params, state, viewModel, clientLocals);
                    });
                  }
                  else {
                    cb(null, params, state, null, null);
                  }
                }
991842
def get_users_in_organization(self, organization_id, start=0, limit=50):
        
        url = 'rest/servicedeskapi/organization/{}/user'.format(organization_id)
        params = {}
        if start is not None:
            params['start'] = int(start)
        if limit is not None:
            params['limit'] = int(limit)

        return self.get(url, headers=self.experimental_headers, params=params)
1044404
function appRequest(params, cb) {
  params = params || {};
  var mbaasConf = params[constants.MBAAS_CONF_KEY];
  params[constants.MBAAS_CONF_KEY] = undefined;
  //Adding Mbaas Config Params
  var fullParams = _.extend(_.clone(params), mbaasConf);

  var invalidParamError = validateAppParams(fullParams);

  if (invalidParamError) {
    return cb(invalidParamError);
  }

  fullParams = _buildAppRequestParams(fullParams);

  return doFHMbaaSRequest(fullParams, cb);
}
1347648
function deleteAccount (name, cb) {
  assert(this instanceof CouchLogin)
  var u = '/_users/org.couchdb.user:' + name
  this.get(u, thenPut.bind(this))

  function thenPut (er, res, data) {
    if (er || res.statusCode !== 200) {
      return cb(er, res, data)
    }

    // user accts can't be just DELETE'd by non-admins
    // so we take the existing doc and just slap a _deleted
    // flag on it to fake it.  Works the same either way
    // in couch.
    data._deleted = true
    this.put(u + '?rev=' + data._rev, data, cb)
  }
}
809315
function deleteUserPolicy (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { userId, organizationId, policyId, instance } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ userId, organizationId, policyId, instance }, validationRules.deleteUserPolicy, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = userId
          job.policyId = policyId
          job.organizationId = organizationId
          job.instance = instance

          next()
        },
        checkUserOrg,
        removeUserPolicy
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        userOps.readUser({ id: userId, organizationId }, cb)
      })

      return promise
    }
1217171
function update (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, name, description, metadata } = params

      Joi.validate({ id, name, description, metadata }, validationRules.update, (err) => {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          UPDATE organizations
          SET
            name = ${name},
            description = ${description},
            metadata = ${metadata}
          WHERE id = ${id}
        `
        db.query(sqlQuery, function (err, result) {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound())

          organizationOps.readById(id, cb)
        })
      })

      return promise
    }
1311086
function deletePolicy (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, organizationId }, validationRules.deletePolicy, (err) => {
            if (err) return next(Boom.badRequest(err))

            next()
          })
        },
        (job, next) => {
          job.id = id
          job.organizationId = organizationId
          next()
        },
        removePolicyFromUsers,
        removePolicyFromTeams,
        removePolicyFromOrganizations,
        removePolicy
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)
        cb()
      })

      return promise
    }
166768
def userinfo_json(request, user_id):
    
    data = {'first_name': '',
            'last_name': '',
            'email': '',
            'slug': '',
            'bio': '',
            'phone': '',
            'is_active': False}

    try:
        member = StaffMember.objects.get(pk=user_id)
        for key in data.keys():
            if hasattr(member, key):
                data[key] = getattr(member, key, '')

    except StaffMember.DoesNotExist:
        pass

    return HttpResponse(json.dumps(data),
                        mimetype='application/json')
1131968
function (params, cb) {

            if (params) {
                params._method = 'POST';
            }

            params.formEncoded = true;

            if (typeof params.file != "undefined" || typeof params.url != "undefined") {

                _util.buildQuery('', params, function (error, data) {

                    return cb(error, data);

                });

            } else {

                return cb(new Error('Please provide file or url path!'));

            }

        }
1328635
function findById(id, cb) {
  db.getClient(function(err, client, done) {
    client.query(SELECT_ID, [id], function(err, r) {
      var result = r && r.rows[0];
      if(!err && !result) err = new exceptions.NotFound();
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
599288
function getDeclensions(callback, providedParams) {
  const params = Object.assign({}, providedParams)
  request.get(params, (err, res, body) => {
    if (err || res.statusCode !== 200) {
      return res.status(500).json({
        error: 'A request to dev.phpbin.ja.is resulted in a error',
      })
    }

    let $
    const sanitisedBody = body.replace(/<!--[\s\S]*?-->/g, '')

    try {
      $ = cheerio.load(sanitisedBody)
    } catch (error) {
      return res.status(500).json({
        error: 'Parsing the data from dev.phpbin.ja.is resulted in a error',
        moreinfo: error,
      })
    }

    // Links mean results!
    const result = $('a')

    // more than 1 result from request (ex: 'hús')
    if (result.length > 1) {
      // call recursively again with new url
      const id = result[0].attribs.on_click.match(/\d+/)[0]
      baseUrl.query = { id }
      params.url = url.format(baseUrl)
      return getDeclensions(callback, params)
    }

    // else just call func to return data
    return callback($)
  })
}
870821
function search (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify('data', 'total')

      const { organizationId, query, type } = params
      Joi.validate({ organizationId, query }, validationRules.searchTeam, function (err) {
        if (err) {
          return cb(Boom.badRequest(err))
        }

        const sqlQuery = SQL`
          SELECT *
          FROM teams
          WHERE org_id=${organizationId}
          AND (
        `
        if (!type || type === 'default') {
          sqlQuery.append(SQL`
            to_tsvector(name) || to_tsvector(description) @@ to_tsquery(${utils.toTsQuery(query)})
              OR name LIKE(${'%' + query + '%'})
          `)
        } else if (type === 'exact') {
          sqlQuery.append(SQL`
            name = ${query}
          `)
        }

        sqlQuery.append(SQL`)
          ORDER BY id;
        `)

        db.query(sqlQuery, (err, result) => {
          if (err) return cb(Boom.badImplementation(err))
          return cb(null, result.rows.map(mapping.team), result.rows.length)
        })
      })

      return promise
    }
298218
function makeRequest(user, auth, url, cb, options = {}, headers = {}) {
    const params = getParams(user, auth, url, options, headers);

    const promise = new Promise((resolve, reject) => {
        request(params, (err, response, body) => {
            if (!err && [200, 201, 204, 301].indexOf(response.statusCode) > -1) {
                const result = _.isString(body) ? JSON.parse(body) : body;
                return resolve([undefined, result]);
            } else {
                if (cb) {
                    return resolve([err || body]);
                }
                return reject([err || body]);
            }
        });
    });
    return handleCallback(promise, cb);
}
1213041
function readTeamUsers ({ id, page = 1, limit, organizationId }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      Joi.validate({ id, page, limit, organizationId }, validationRules.readTeamUsers, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const pageLimit = limit || _.get(config, 'authorization.defaultPageSize')
        const offset = (page - 1) * pageLimit

        const job = {
          id: id,
          organizationId: organizationId,
          offset: offset,
          limit: pageLimit,
          team: {},
          client: db
        }

        loadTeamUsers(job, (err) => {
          if (err) return cb(err)
          const pageSize = pageLimit || job.totalUsersCount
          const result = {
            page: page,
            limit: pageSize,
            total: job.totalUsersCount,
            data: job.team.users
          }
          return cb(null, result)
        })
      })

      return promise
    }