Create a new user

@param  {Object}   params { id, name, organizationId, metadata } "id" & "metadata" can be null
@param  {Function} cb
353523
function createUser (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

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

      Joi.validate({ id, name, organizationId }, validationRules.createUser, function (err) {
        if (err) return cb(Boom.badRequest(err))

        userOps.organizationExists(organizationId, (err, res) => {
          if (err) return cb(err)
          if (!res) return cb(Boom.badRequest(`Organization '${organizationId}' does not exist`))

          userOps.insertUser(db, { id, name, organizationId, metadata }, (err, result) => {
            if (err) return cb(err)

            userOps.readUser({ id: result.rows[0].id, organizationId }, utils.boomErrorWrapper(cb))
          })
        })
      })

      return promise
    }
1275860
function createSession(config, cb) {
  checkOpts(config, cb)

  cb = utils.callOnce(cb)

  var url = config.url
  var key = config.key

  config = {
    url: url,
    key: key
  }

  session.createSession(config, cb)
}
773455
function create(body, cb) {
  var validates = Schema(body);

  if(!validates) {
    return cb(new exceptions.BadRequest());
  }

  db.getClient(function(err, client, done) {
    client.query(INSERT, [body.post_id, body.tag_id], function(err, r) {
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, r.rows[0]);
        done();
      }
    });
  });
}
1318972
function addTeamPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params

      Joi.validate({ id, organizationId, policies: params.policies }, validationRules.addTeamPolicies, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const policies = utils.preparePolicies(params.policies)

        utils.checkPoliciesOrg(db, policies, organizationId, (err) => {
          if (err) return cb(err)

          insertTeamPolicies({ client: db, teamId: id, policies }, (err, res) => {
            if (err) return cb(err)
            teamOps.readTeam({ id, organizationId }, cb)
          })
        })
      })

      return promise
    }
1059244
function createAdminUser(app, result, callback) {
  // Create the admin user.
  var User = app.type('user');
  var userData = {
    username: result.adminName,
    password: result.adminPass,
    email: result.adminEmail,
    roles: ['administrator']
  };
  User.validateAndSave(userData, callback);
}
1168304
function replaceUserTeams (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

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

          next()
        },
        checkUserOrg,
        (job, next) => {
          utils.checkTeamsOrg(job.client, job.teams, job.organizationId, next)
        },
        clearUserTeams,
        insertUserTeams
      ]

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

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

      return promise
    }
325317
function createUser (req, res, next) {
    User.insert(req.body, { private: true }, function (err, user) {
      if (err) {
        res.render('signup', {
          params: qs.stringify(req.body),
          request: req.body,
          providers: settings.providers,
          error: err.message
        })
      } else {
        authenticator.dispatch('password', req, res, next, function (err, user, info) {
          if (err) { return next(err) }
          if (!user) {
          } else {
            authenticator.login(req, user)
            req.sendVerificationEmail =
              req.provider.emailVerification.enable
            req.flash('isNewUser', true)
            next()
          }
        })
      }
    })
  }
267064
function createUsersDatabase (emailAddress, secret, name, retries) {
    nano.db.create('users', function (e, b, h) {
      userCreate(emailAddress, secret, name, retries + 1)
    })
  }
898424
function createUser(req, res, next){

        // the HTML form names are conveniently named the same as
        // the UserApp fields...
        var user = req.body;

        // Create the user in UserApp
        UserApp.User.save(user, function(err, user){

            // We can just pass through messages like "Password must be at least 5 characters." etc.
            if (err) return res.render('signup', {user: false, message: err.message});

            // UserApp passport needs a username parameter
            req.body.username = req.body.login;

            //on to authentication
            next();
        });

    // authenticate the user using passport
}
566949
function create(user, callback) {
      var cb = callback || angular.noop;

      return User.create(user,
        function (user) {
          return cb(user);
        },
        function (err) {
          return cb(err);
        }).$promise;
    }
571279
function create(connections, dataTarget, cb) {
  async.waterfall([
    function validateParams(cb) {
      validate(dataTarget).hasno(CONSTANTS.DATA_TARGET_ID, function(err) {
        if (err) {
          return cb(buildErrorResponse({error: new Error("Data Target ID Should Not Be Included When Creating A Data Target"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
        }
      });

      cb(undefined, dataTarget);
    },
    function createDataTarget(dataTargetJSON, cb) {
      dataTargetJSON = sanitiseJSON(dataTargetJSON);

      var DataTarget = models.get(connections.mongooseConnection, models.MODELNAMES.DATA_TARGET);
      var newDataTarget = new DataTarget(dataTargetJSON);

      newDataTarget.save(function(err) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Invalid Data Target Creation Data.",
            systemDetail: err.errors,
            code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS
          }));
        }

        return cb(undefined, newDataTarget.toJSON());
      });

    }
  ], cb);
}
623412
function create(callback, payee, name) {
  if(!util.isFunction(callback)) {
    throw new Error('callback must be a function');
  }

  var resource = this.coinjar.personal.api_endpoint + '/v1/contacts.json',
    query = {
      contact : {}
    };

  if(payee) { query.contact.payee = payee; }
  if(name) { query.contact.name = name; }

  request.post(resource)
    .auth(this.coinjar.personal.auth_token)
    .send(query)
    .end(function (response) {
      if(isResponseError(response, callback)) { return; }
      return callback(null, response.body.contact);
    });
}
1216725
function setRequestId(id, cb) {
  var ns = getLoggerNamespace();
  ns.run(function() {
    ns.set('requestId', id);
    cb();
  });
}
619949
function make_request(params, cb) {

  var options =
  { uri: params.uri
  , method: params.method
  , headers: params.headers
  }

  if (params.body) options.body = params.body
  else options.headers['content-length'] = 0

  debug("making request", options)
  request.make(options, function (error, response, body) {
    cb(error, response)
  })
}
1369673
def create_user(username, password=None, email=None, first_name="", last_name="",
                role="MEMBER", login_method=None):
    

    if not login_method:
        login_method = "email" if "@" in username else "username"

    def cb():
        return _user(models.AuthUser.new(username=username,
                                         password=password,
                                         email=email,
                                         first_name=first_name,
                                         last_name=last_name,
                                         login_method=login_method,
                                         role=role))

    return signals.create_user(cb)
212687
function create_new() {
        var id

        // Check if we already have an id or if
        // we need to generate a new one.
        if (undefined !== ent.id$) {
          // Take a copy of the existing id and
          // delete it from the ent object. Do
          // save will handle the id for us.
          id = ent.id$
          delete ent.id$

          // Save with the existing id
          return do_save(id, true)
        }

        // Generate a new id
        id = options.generate_id ? options.generate_id(ent) : void 0

        if (undefined !== id) {
          return do_save(id, true)
        } else {
          var gen_id = {
            role: 'basic',
            cmd: 'generate_id',
            name: name,
            base: base,
            zone: zone
          }

          // When we get a respones we will use the id param
          // as our entity id, if this fails we just fail and
          // call reply() as we have no way to save without an id
          seneca.act(gen_id, function(err, id) {
            if (err) return reply(err)
            do_save(id, true)
          })
        }
      }
491600
function(user) {
                console.log('oauthInterface.user.create', user);

                return this.request({
                        url: this._buildUri(this.uri),
                        method: corbel.request.method.POST,
                        headers: {
                            Authorization: 'Basic ' + this.getSerializer()(this.clientId + ':' + this.clientSecret)
                        },
                        dataType: 'text',
                        data: user
                    })
                    .then(function(res) {
                        return corbel.Services.getLocationId(res);
                    });
            }