Change the password with logging

@param string $username     the username
@param string $new_password the new password

@return boolean true
358355
public static function changePassword($username , $new_password)
	{
		self::setUser( $username , $new_password );
		self::log( 'changepwd' , $username );
		self::save();

		return true;
	}
78100
public static function changePasswordByCodeWithUsername($username, $code, $newPassword, $login)
    {
        return static::changePasswordByCode(static::getEmailByUsername($username), $code, $newPassword, $login);
    }
868313
function user_update_password($user, $newpassword) {
        $user = get_complete_user_data('id', $user->id);
        // This will also update the stored hash to the latest algorithm
        // if the existing hash is using an out-of-date algorithm (or the
        // legacy md5 algorithm).
        return update_internal_user_password($user, $newpassword);
    }
327537
public function changePassword($password_token, $new_password)
	{
		if ($this->checkPasswordToken($password_token)) {
			$this->password                     = $new_password;
			$this->attributes['password_token'] = null;
			FuzzAuthUserProvider::revokeSessionsForOwnerTypeAndId('user', $this->{$this->getKey()});

			return true;
		}

		return false;
	}
1256506
function user_login($username, $password) {
        global $CFG, $DB;

        if ($this->is_configured() === false) {
            debugging(get_string('auth_notconfigured', 'auth', $this->authtype));
            return false;
        }

        $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding);
        $extpassword = core_text::convert($password, 'utf-8', $this->config->extencoding);

        if ($this->is_internal()) {
            // Lookup username externally, but resolve
            // password locally -- to support backend that
            // don't track passwords.

            if (isset($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_KEEP) {
                // No need to connect to external database in this case because users are never removed and we verify password locally.
                if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
                    return validate_internal_user_password($user, $password);
                } else {
                    return false;
                }
            }

            $authdb = $this->db_init();

            $rs = $authdb->Execute("SELECT *
                                      FROM {$this->config->table}
                                     WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
            if (!$rs) {
                $authdb->Close();
                debugging(get_string('auth_dbcantconnect','auth_db'));
                return false;
            }

            if (!$rs->EOF) {
                $rs->Close();
                $authdb->Close();
                // User exists externally - check username/password internally.
                if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
                    return validate_internal_user_password($user, $password);
                }
            } else {
                $rs->Close();
                $authdb->Close();
                // User does not exist externally.
                return false;
            }

        } else {
            // Normal case: use external db for both usernames and passwords.

            $authdb = $this->db_init();

            $rs = $authdb->Execute("SELECT {$this->config->fieldpass}
                                      FROM {$this->config->table}
                                     WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
            if (!$rs) {
                $authdb->Close();
                debugging(get_string('auth_dbcantconnect','auth_db'));
                return false;
            }

            if ($rs->EOF) {
                $authdb->Close();
                return false;
            }

            $fields = array_change_key_case($rs->fields, CASE_LOWER);
            $fromdb = $fields[strtolower($this->config->fieldpass)];
            $rs->Close();
            $authdb->Close();

            if ($this->config->passtype === 'plaintext') {
                return ($fromdb == $extpassword);
            } else if ($this->config->passtype === 'md5') {
                return (strtolower($fromdb) == md5($extpassword));
            } else if ($this->config->passtype === 'sha1') {
                return (strtolower($fromdb) == sha1($extpassword));
            } else if ($this->config->passtype === 'saltedcrypt') {
                return password_verify($extpassword, $fromdb);
            } else {
                return false;
            }

        }
    }
358415
public final boolean resetPassword(String token, String newpass) {
		if (StringUtils.isBlank(newpass) || StringUtils.isBlank(token) || newpass.length() < Config.MIN_PASS_LENGTH) {
			return false;
		}
		Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
		if (isValidToken(s, Config._RESET_TOKEN, token)) {
			s.removeProperty(Config._RESET_TOKEN);
			String hashed = Utils.bcrypt(newpass);
			s.addProperty(Config._PASSWORD, hashed);
			setPassword(hashed);
			CoreUtils.getInstance().getDao().update(getAppid(), s);
			return true;
		}
		return false;
	}
1151674
public function login($username, $password)
    {
        // @ - intentionally, because false is enough
        if (@ftp_login($this->stream, $username, $password)) {
            $this->loggedIn = true;
            return true;
        } else {
            return false;
        }
    }
629838
public static function setAdmin($username , $password = null , $logs = null)
	{
		return self::setUser( $username , $password , $roles = array('admin') , $logs );
	}
564229
public function changePasswordWithRecoveryToken(User $user, int $tokenId, string $token, string $newPassword)
    {
        if (!$this->resetTokenProvider) {
            throw new PasswordResetProhibitedException('The configuration currently prohibits the resetting of passwords!');
        }

        $auth = $this->authenticationProvider->findByUserId($user->getId());
        if (!$auth) {
            throw new NoSuchUserException();
        }

        $remote = new RemoteAddress();
        $remote->setUseProxy(true);

        $resetToken = $this->resetTokenProvider->get($tokenId);
        if (!$resetToken) {
            throw new InvalidResetTokenException();
        }

        if (!$resetToken->isValid($auth, $token, $remote->getIpAddress(), $this->validateFingerprint, $this->validateIp)) {
            throw new InvalidResetTokenException();
        }

        $this->resetPassword($user, $newPassword);
        $resetToken->setStatus(UserResetTokenInterface::STATUS_USED);
        $this->resetTokenProvider->update($resetToken);
    }
373148
public function updatePassword($username, $password)
    {
        /** @var UserInterface|EloquentUser $user */
        if ( ! ($user = $this->sentinel->findByCredentials(['email' => $username]))) {
            return false;
        }

        return $this->sentinel->update($user, ['password' => $password]) instanceof UserInterface;
    }
1175672
public function updatePassword($token, $oldPassword, $newPassword)
    {
        return $this->bizImpl->updatePassword($token, $oldPassword, $newPassword);
    }
379891
public function changeUserPassword(string $uid, string $newPassword): ResponseInterface
    {
        return $this->updateUser(
            Request\UpdateUser::new()
                ->withUid($uid)
                ->withClearTextPassword($newPassword)
        );
    }
434049
public function Login ($username = '', $password = '') {
    if ($this->connected == false) {
      $this->error = 'Not connected to POP3 server';

      if ($this->do_debug >= 1) {
        $this->displayErrors();
      }
    }

    if (empty($username)) {
      $username = $this->username;
    }

    if (empty($password)) {
      $password = $this->password;
    }

    $pop_username = "USER $username" . $this->CRLF;
    $pop_password = "PASS $password" . $this->CRLF;

    //  Send the Username
    $this->sendString($pop_username);
    $pop3_response = $this->getResponse();

    if ($this->checkResponse($pop3_response)) {
      //  Send the Password
      $this->sendString($pop_password);
      $pop3_response = $this->getResponse();

      if ($this->checkResponse($pop3_response)) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
507443
public function basic(string $username, string $password)
    {
        $this->type = self::BASIC;
        $this->username = $username;
        $this->password = $password;
    }
1033192
public function login($username = '', $password = '')
    {
        if (!$this->connected) {
            $this->setError('Not connected to POP3 server');
        }
        if (empty($username)) {
            $username = $this->username;
        }
        if (empty($password)) {
            $password = $this->password;
        }

        // Send the Username
        $this->sendString("USER $username" . static::LE);
        $pop3_response = $this->getResponse();
        if ($this->checkResponse($pop3_response)) {
            // Send the Password
            $this->sendString("PASS $password" . static::LE);
            $pop3_response = $this->getResponse();
            if ($this->checkResponse($pop3_response)) {
                return true;
            }
        }

        return false;
    }
688750
function reset_password($username,$newpassword){
        if(empty($username) || empty($newpassword)){
            return false;
        }
        $token = $this->get_token();
        $header = array('Authorization: Bearer '.$token);
        $path = 'users/'.$username.'/password';
        $request_body = array("newpassword"=>$newpassword);

        //确保执行成功
        $return = false;
        while($return===false){
            $result = $this->api_request($path, json_encode($request_body,JSON_UNESCAPED_UNICODE) , 'PUT', $header);
            $return = $this->result_handler($result);
        }

        return $return;
    }
490229
protected function authenticate(string $username, string $password)
    {
        if (!isset($this->users[$username]) || $this->users[$username]['password'] != $password) {
            return false;
        }

        return true;
    }