START OF HELPER FUNCTIONS* 
adds user if not exists.
342126
function addUser(username) {
		return userProject.findOne({'username': username}).exec()
		.then(function(doc) {
			if (!doc) {
				return userProject.create(userProjectJSON(username));
			}
			return Promise.resolve(doc);
		});
	}
935803
def register_helper(self, func):
        

        self._helper_names.add(func.__name__)
        return self.register(func)
495248
def add_users(self, category):
        """"""
        mapping = {'banned': 'ban', 'contributor': 'make_contributor',
                   'moderator': 'make_moderator'}

        if category not in mapping:
            print('{!r} is not a valid option for --add'.format(category))
            return
        func = getattr(self.sub, mapping[category])
        print('Enter user names (any separation should suffice):')
        data = sys.stdin.read().strip()
        for name in re.split('[^A-Za-z0-9_]+', data):
            func(name)
            print('Added {!r} to {}'.format(name, category))
478595
function users() {

	var seminarjs = this;

	var exports = {};

	exports.list = [];

	/**
	 * Add a user
	 * @param {string} name       User name
	 * @param {Object} attributes List of attributes to be added to the user
	 */
	exports.add = function (name, attributes) {
		if (exports.find(name)) {
			return false;
		} else {
			exports.list.push(new User(name, attributes));
		}
	};

	/**
	 * Finds users
	 * @param  {string} name User name
	 * @return {int}	Integer >-1 if the user is found, or -1 if not.
	 */
	exports.find = function (name) {
		var total = exports.list.length;

		for (var i = 0; i < total; i++) {
			if (exports.list[i].name == name) {
				return i;
			}
		}

		return -1;
	};

	/**
	 * Removes a user from the list
	 * @param  {string} name User name
	 */
	exports.remove = function (name) {
		var index = exports.find(name);

		exports.list.splice(index, 1);
	};

	/**
	 * Set a property for a user
	 * @param {string} name  Username
	 * @param {String} param Parameter name
	 * @param {String} value Parameter value
	 */
	exports.set = function (name, param, value) {
		var index = exports.find(name);

		exports.list[index][param] = value;
	};

	/**
	 * Get a parameter
	 * @param  {string} name  User name
	 * @param  {String} param Parameter name
	 * @return {String}       Parameter value
	 */
	exports.get = function (name, param) {
		var index = exports.find(name);

		return exports.list[index][param];
	};

	/**
	 * User constructor
	 * @param {string} name       User name
	 * @param {object} attributes User properties
	 */
	function User(name, attributes) {
		var ret = {
			name: user
		};

		return extend(ret, attributes);
	}

	return exports;
}
922515
def add_user(self, user, is_admin=False):
        
        users_count = self.users.all().count()
        if users_count == 0:
            is_admin = True
        # TODO get specific org user?
        org_user = self._org_user_model.objects.create(
            user=user, organization=self, is_admin=is_admin
        )
        if users_count == 0:
            # TODO get specific org user?
            self._org_owner_model.objects.create(
                organization=self, organization_user=org_user
            )

        # User added signal
        user_added.send(sender=self, user=user)
        return org_user
172469
def add(self, user, password):
        
        if self.__contains__(user):
            raise UserExists
        self.new_users[user] = self._encrypt_password(password) + "\n"
396493
def put(self, user_name: str) -> User:
        
        current = current_user()
        if current.name == user_name or current.is_admin:
            user = self._get_or_abort(user_name)
            self.update(user)
            session.commit()
            session.add(user)
            return user
        else:
            abort(403)
1282515
function userExists(user) {
  if (_.isEmpty(findUser(user, {refresh: true, throwIfNotFound: false}))) {
    return false;
  } else {
    return true;
  }
}
448649
function createUser(form) {
      // refuse to work with invalid data
      if (vm.user._id || (form && !form.$valid)) {
        return;
      }

      Auth.createUser(vm.user)
        .then(createUserSuccess)
        .catch(createUserCatch);

      function createUserSuccess(newUser) {
        Toast.show({
          type: 'success',
          text: 'User ' + newUser.name + ' has been created',
          link: {state: 'admin.user.list.detail', params: {id: newUser._id}}
        });
        vm.close();
      }

      function createUserCatch(err) {
        if (form && err) {
          form.setResponseErrors(err);
        }

        Toast.show({
          type: 'warn',
          text: 'Error while creating a new user'
        });
      }
    }
956562
function (n) {
            //get user from db
            dbAction.get("findByUserId", userId, function (err, u) {
                if (u) {
                    user = u.toObject();
                }
                else {
                    err = err || new Error("User not found by userId: " + userId);
                }
                n(err);
            })
        }
107108
def init
      File.exist?(EXCLUDE_FILE) ? @logger.info('skip: creation excludes.d') : create_exclude_config
      Dir.exist?(ROLE_DIR) ? @logger.info('skip: creation roles.d') : create_roles_dir
      Dir.exist?(USER_DIR) ? @logger.info('skip: creation users.d') : create_users_dir
    end
962730
def create_user(self, **kwargs):
        """"""
        roles = kwargs.pop('roles', [])
        user = self.user_model(**self._prepare_create_user_args(**kwargs))
        user = self.put(user)
        for role in roles:
            self.add_role_to_user(user, role)
        self.put(user)
        return user
205858
def handle_add(self, options):
        
        username = options["username"]
        passwd = options["passwd"]
        if passwd is None:
            passwd = User.objects.make_random_password()
        user = User.objects.create_user(username, options["email"], passwd)

        if options["staff"]:
            user.is_staff = True
        if options["superuser"]:
            user.is_superuser = True
        user.save()

        if options["passwd"] is None:
            self.stdout.write(passwd)
867939
def add_user(
        self,
        name, 
        **attrs
        ):
        """"""
        if self.user_exists(name):
            raise KubeConfError("user with the given name already exists.")

        users = self.get_users()
        
        # Add parameters.
        new_user = {'name': name, 'user':{}}
        attrs_ = new_user['user']
        attrs_.update(attrs)
        users.append(new_user)
339106
protected void addUser(UaaUser user) {
        ScimUser scimUser = getScimUser(user);
        if (scimUser==null) {
            if (isEmpty(user.getPassword()) && user.getOrigin().equals(OriginKeys.UAA)) {
                logger.debug("User's password cannot be empty");
                throw new InvalidPasswordException("Password cannot be empty", BAD_REQUEST);
            }
            createNewUser(user);
        }
        else {
            if (override) {
                updateUser(scimUser, user);
            } else {
                logger.debug("Override flag not set. Not registering existing user: " + user);
            }
        }
    }
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
977054
public void addUserInUserManager(User user) {
        if (!userManager.getUserList().contains(user.getUsername())) {
            try {
                userManager.createUser(user.getUsername());
            } catch (UserExistsException e) {
                LOGGER.warn("User already exists!", e);
                return;
            }
        }
        for (Attribute attribute : user.getAttributes()) {
            userManager.setUserAttribute(user.getUsername(), attribute.getAttributeName(), attribute.getValues()
                    .toArray());
        }
    }