Merge the inline user/pass with the default user/pass, giving
 precedence to inline.
502198
def make_credentials(inline_user, inline_password)
      user = inline_user || @default_user
      user = nil if user && user.empty?
      password = (inline_password || @default_password)
      password = nil if password && password.empty?
      [user, password]
    end
1370480
def MergeOrAddUser(self, kb_user):
    

    user = self.GetUser(
        sid=kb_user.sid, uid=kb_user.uid, username=kb_user.username)
    new_attrs = []
    merge_conflicts = []  # Record when we overwrite a value.
    if not user:
      new_attrs = self._CreateNewUser(kb_user)
    else:
      for key, val in iteritems(kb_user.AsDict()):
        if user.Get(key) and user.Get(key) != val:
          merge_conflicts.append((key, user.Get(key), val))
        user.Set(key, val)
        new_attrs.append("users.%s" % key)

    return new_attrs, merge_conflicts
513067
def users_me_merge(self, data, **kwargs):
        ""
        api_path = "/api/v2/users/me/merge.json"
        return self.call(api_path, method="PUT", data=data, **kwargs)
606063
def _merge_on_matching(self, uuid, matcher, verbose):
        """"""

        matches = api.match_identities(self.db, uuid, matcher)

        new_uuid = uuid

        u = api.unique_identities(self.db, uuid)[0]

        for m in matches:
            if m.uuid == uuid:
                continue

            self._merge(u, m, verbose)

            new_uuid = m.uuid

            # Swap uids to merge with those that could
            # remain on the list with updated info
            u = api.unique_identities(self.db, m.uuid)[0]

        return new_uuid
573027
def _insert_defaults(self):
        
        merged = merge_defaults(self.structure, self)
        self.update(merged)
219257
def conf_merger(user_dict, variable):
    
    if variable not in globals().keys():
        raise NameError("Unknown variable '%s'." % variable)

    if variable not in user_dict:
        return globals()[variable]

    return globals()[variable] and user_dict[variable]
374147
def soft_merge(u2)
			# we want automatic unescaping of u2 components
			u2 = self.class.new(u2) unless u2.is_a?(self.class)
			# only merge if we are both opaque or path like
			if opaque.nil? == u2.opaque.nil?
				components = uri.component
				if components.include?(:userinfo)
					components += %i[user password]
					components.delete(:userinfo)
				end
				components.each do |m|
					# path returns "" by default but we don't want to merge in this case
					if u2.respond_to?(m) && (v = u2.public_send(m)) && !((v == "") && (m == :path))
						uri.public_send(:"#{m}=", v)
					end
				end
			end
			self
		end
1321976
def _splituser(host):
    """"""
    user, delim, host = host.rpartition('@')
    return (user if delim else None), host
140134
public function merge()
	{
		$sourceUser           = 0;
		$destinationUser      = 0;
		$directionalIndicator = $this->arguments->getOpt(4);

		if ($directionalIndicator)
		{
			switch ($directionalIndicator)
			{
				case 'into':
					$sourceUser      = (int)$this->arguments->getOpt(3);
					$destinationUser = (int)$this->arguments->getOpt(5);
					break;

				default:
					// Do nothing...can't assume
					break;
			}

			if ((!$sourceUser || !$destinationUser) && !$this->output->isInteractive())
			{
				$this->output->error('Please provide a source and destination user in the format: muse user merge [sourceUserId] into [destUserId]');
			}
		}
		else
		{
			if ($this->output->isInteractive())
			{
				$destinationUser = (int)$this->output->getResponse('What is the destination user ID (this is the user that will remain after the merge)?');
				$sourceUser      = (int)$this->output->getResponse('What is the source user ID (this is the user that will be deleted after the merge)?');
			}
			else
			{
				$this->output->error('Please provide a source and destination user in the format: muse user merge [sourceUserId] into [destUserId]');
			}
		}

		$suser  = \User::getInstance($sourceUser);
		$duser  = \User::getInstance($destinationUser);
		$dbo    = App::get('db');
		$tables = $dbo->getTableList();
		$prefix = $dbo->getPrefix();
		$fields = array(
			'created_by', 'modified_by', 'reviewed_by', 'user_id', 'userid', 'authorid', 'checked_out', 'uid',
			'uidNumber', 'created_user_id', 'modified_user_id', 'object_id', 'follower_id', 'following_id',
			'sent_by', 'redeemed_by', 'userid', 'creator_id', 'addedBy', 'editedBy', 'user_id_to', 'user_id_from',
			'commenter', 'uploaded_by', 'posted_by', 'assigned_to', 'closed_by', 'owned_by_user', 'created_by_user',
			'ran_by', 'foreign_key', 'taggerid', 'actor_id', 'voter', 'proposed_by', 'granted_by', 'assigned',
			'approved_by', 'action_by', 'authorid'
		);
		$unames = array(
			$prefix . 'event_registration.username',
			//$prefix . 'resource_stats_clusters.username',
			//$prefix . 'resource_stats_tools_users.user',
			//$prefix . 'session_geo.username',
			$prefix . 'support_acl_aros.alias',
			$prefix . 'support_comments.created_by',
			$prefix . 'support_tickets.login',
			$prefix . 'tool.team',
			$prefix . 'tool.registered_by',
			$prefix . 'tool_version.released_by',
			$prefix . 'wiki_page.authors'
		);
		$excludes = array(
			$prefix . 'xprofiles',
			$prefix . 'session_log',
			$prefix . 'session',
			$prefix . 'users_quotas'
		);
		$constraints = array(
			$prefix . 'collections.object_id'              => "AND `object_type` = 'member'",
			$prefix . 'collections_following.follower_id'  => "AND `follower_type` = 'member'",
			$prefix . 'collections_following.following_id' => "AND `following_type` = 'member'",
			$prefix . 'support_acl_aros.foreign_key'       => "AND `model` = 'user'",
			$prefix . 'support_acl_aros.alias'             => "AND `model` = 'user'"
		);

		// First, make sure we were given valid user ids
		if (!$suser->get('id') || !$duser->get('id'))
		{
			$this->output->error('User does not appear to be valid');
		}

		// Secondly, make sure this user hasn't been involved in a merge beforehand
		$query = "SELECT `id` FROM `#__users_merge_log` WHERE `source` = '{$sourceUser}'";
		$dbo->setQuery($query);
		if ($dbo->loadResult())
		{
			$this->output->error('This user appears to have already been merged into another user.');
		}

		foreach ($tables as $table)
		{
			// Ignore a few tables
			if (in_array($table, $excludes))
			{
				continue;
			}

			// Figure out what the table's primary key is
			$query = "SHOW INDEX FROM `{$table}` WHERE `Key_name` = 'PRIMARY'";
			$dbo->setQuery($query);
			$index = $dbo->loadObject();
			$tablePK = (isset($index->Column_name)) ? $index->Column_name : false;

			// Get the columns
			$columns = $dbo->getTableColumns($table);

			// Loop over columns and see if they're in our list from above
			foreach ($columns as $column => $type)
			{
				if (in_array($table.'.'.$column, $unames) || in_array($column, $fields))
				{
					$sUserName = $suser->get('username');
					$dUserName = $duser->get('username');

					// We have a match, now check if there are rows to merge
					$query  = "SELECT * FROM `{$table}` WHERE `{$column}` = '{$sourceUser}' OR `{$column}` LIKE '%{$sUserName}%'";
					$query .= ((isset($constraints[$table.'.'.$column])) ? ' ' . $constraints[$table.'.'.$column]: '');
					$dbo->setQuery($query);
					$results = $dbo->loadObjectList();

					if ($results && count($results) > 0)
					{
						$count = count($results);
						foreach ($results as $row)
						{
							if (!$tablePK)
							{
								$this->output->addLine("Ignoring {$table}.{$column} due to lack of primary key", 'warning');
								continue 2;
							}

							if (!$this->arguments->getOpt('dry-run'))
							{
								try
								{
									$numericUpdate = true;
									if (is_numeric($row->$column))
									{
										$query = "UPDATE `{$table}` SET `{$column}` = '{$destinationUser}' WHERE `{$tablePK}` = '{$row->$tablePK}'";
									}
									else
									{
										$numericUpdate = false;
										$query = "UPDATE `{$table}` SET `{$column}` = REPLACE({$column}, '{$sUserName}', '{$dUserName}') WHERE `{$tablePK}` = '{$row->$tablePK}'";
									}

									$dbo->setQuery($query);
									$dbo->query();

									// Now log it
									$log              = new \stdClass();
									$log->source      = ($numericUpdate) ? $sourceUser : $sUserName;
									$log->destination = ($numericUpdate) ? $destinationUser : $dUserName;
									$log->table       = $table;
									$log->column      = $column;
									$log->table_pk    = $tablePK;
									$log->table_id    = $row->$tablePK;
									$log->logged      = with(new Date('now'))->toSql();
									$dbo->insertObject('#__users_merge_log', $log);
								}
								catch (\Hubzero\Database\Exception\QueryFailedException $e)
								{
									if ($e->getPrevious()->getCode() == '23000')
									{
										$this->output->addLine("Ignoring {$table}.{$column} due to integrity constraint violation", 'warning');
										continue 2;
									}
									else
									{
										$this->output->error("Error: " . $e->getMessage());
									}
								}
							}
						}
						if ($this->arguments->getOpt('dry-run'))
						{
							$this->output->addLine("Would update ({$count}) item(s) in {$table}.{$column}");
						}
						else
						{
							$this->output->addLine("Updating ({$count}) item(s) in {$table}.{$column}", 'success');
						}
					}
				}
			}
		}

		// Lastly, block the user being merged
		if (!$this->arguments->getOpt('dry-run'))
		{
			$suser->set('block', 1);
			$suser->save();
		}
	}
346575
def user_pass(self, func=None, location=None, **rkwargs):
        """"""
        def wrapper(view):
            view = to_coroutine(view)

            @functools.wraps(view)
            async def handler(request, *args, **kwargs):
                await self.check_user(request, func, location, **rkwargs)
                return await view(request, *args, **kwargs)
            return handler

        return wrapper
149182
function merge(prev, current, next) {
  return prev
    .concat()
    .reverse()
    .concat([current], next)
}
840386
def user(ctx, username, password):
    """"""

    ctx.obj['username'] = username
    ctx.obj['password'] = password
724705
function mergeOptions(config, pass) {
      var _this = this;

      var result = loadConfig(config);

      var plugins = result.plugins.map(function (descriptor) {
        return loadPluginDescriptor(descriptor);
      });
      var presets = result.presets.map(function (descriptor) {
        return loadPresetDescriptor(descriptor);
      });

      if (config.options.passPerPreset != null && typeof config.options.passPerPreset !== "boolean") {
        throw new Error(".passPerPreset must be a boolean or undefined");
      }
      var passPerPreset = config.options.passPerPreset;
      pass = pass || this.passes[0];

      // resolve presets
      if (presets.length > 0) {
        var presetPasses = null;
        if (passPerPreset) {
          var _passes;

          presetPasses = presets.map(function () {
            return [];
          });
          // The passes are created in the same order as the preset list, but are inserted before any
          // existing additional passes.
          (_passes = this.passes).splice.apply(_passes, [1, 0].concat((0, _toConsumableArray3.default)(presetPasses)));
        }

        presets.forEach(function (presetConfig, i) {
          _this.mergeOptions(presetConfig, presetPasses ? presetPasses[i] : pass);
        });
      }

      // resolve plugins
      if (plugins.length > 0) {
        var _pass;

        (_pass = pass).unshift.apply(_pass, (0, _toConsumableArray3.default)(plugins));
      }

      (0, _merge2.default)(this.options, result.options);
    }
866100
function setDefaultUser (kontx, next) {
        var a = _.clone(kontx.args);

        if (a.length === 0) { //No args are sent in, set first to be user id
            a[0] = kontx.user._id;
        }
        else if (_.has(a[0], 'include') || _.has(a[0], 'exclude')) { // If first arg is options then reassign
            a[0] = kontx.user._id;
            a[1] = kontx.args[0];
        }

        kontx.args = a;
        next();
    }
982381
def merge(self, other):
        
        if not isinstance(other, NameVariants):
            raise TypeError("NameVariants isinstance can be merge with"
                            "other isinstance of the same class")
        for key in self.variants:
            self.variants[key] = self.variants[key] or other.variants[key]

        return self
1341636
def merge(self, other):
        """"""
        assert self.attrs == other.attrs
        self.tokens.extend(other.tokens)
        self.spaces.extend(other.spaces)
        self.strings.update(other.strings)
1314357
def _legacy_add_user(self, name, password, read_only, **kwargs):
        
        # Use a Collection with the default codec_options.
        system_users = self._collection_default_options('system.users')
        user = system_users.find_one({"user": name}) or {"user": name}
        if password is not None:
            user["pwd"] = auth._password_digest(name, password)
        if read_only is not None:
            user["readOnly"] = read_only
        user.update(kwargs)

        # We don't care what the _id is, only that it has one
        # for the replace_one call below.
        user.setdefault("_id", ObjectId())
        try:
            system_users.replace_one({"_id": user["_id"]}, user, True)
        except OperationFailure as exc:
            # First admin user add fails gle in MongoDB >= 2.1.2
            # See SERVER-4225 for more information.
            if 'login' in str(exc):
                pass
            # First admin user add fails gle from mongos 2.0.x
            # and 2.2.x.
            elif (exc.details and
                  'getlasterror' in exc.details.get('note', '')):
                pass
            else:
                raise