Update Password

@param $username
@return mixed
1675
public function mailPasswordResetLink($username)
    {
        return $this->apiClient->callEndpoint(
            sprintf('user/mail/password?username=%s', $username),
            array(),
            null,
            HttpMethod::REQUEST_POST
        );
    }
1365196
public function updatePasswordByEmail($email, $password)
    {
        // Retrieve user by e-mail
        $user = $this->authModel->where('email', '=', $email)->first();

        if (empty($user)) {
            return false;
        }

        $user->password = $password;

        // Update user with new password
        return (bool) $user->update();
    }
1201158
public function updateUser($userLogin, $password = '', $email = '', $alias = '', array $optional = [])
    {
        return $this->_request('UsersManager.updateUser', [
            'userLogin' => $userLogin,
            'password' => $password,
            'email' => $email,
            'alias' => $alias,
        ], $optional);
    }
564501
public function setUsername($username = null)
    {
        if ($username === null && ($model = $this->getUsername()->one())) {
            return $model->delete() > 0;
        }
        if ($username instanceof Username) {
            $username = $username->content;
        }
        $model = $this->createUsername($username);
        return $model->save();
    }
402357
public function setPassword($userId, $password)
    {
        $sql = "UPDATE CF_MEMBER SET USER_PASS = hashbytes('sha1', ?) WHERE USN = ?";
        $stmt = $this->getEntityManager()->getConnection()->prepare($sql);
        $stmt->execute([$password, $userId]);

        return $stmt->fetch();
    }
340491
public function getPersonalToken($username, $password)
    {
        $response = $this->client->request('POST', $this->authorization_url(),
            [
                "auth" => [ $username, $password],
                "json" => $this->authorizationsRequestJson()
            ]
        );
        $response = json_decode($response->getBody());
        $this->tokenName = $response->app->name;
        return $response->token;
    }
1245935
protected function authenticate($username, $password)
    {
        if (!isset($username)) {
            return ValidationResult::error("username isn't set");
        }
        
        if (!isset($password)) {
            return ValidationResult::error("password isn't set");
        } 
        
        if (!isset(self::$users[$username]) || !password_verify($password, self::$users[$username]['password'])) {
            return ValidationResult::error("Invalid credentials");
        }

        return ValidationResult::success();
    }
761506
public function checkUserCredentials($username, $password)
    {
        if ($user = $this->getUser($username)) {
            return $this->checkPassword($user, $password);
        }

        return false;
    }
907506
public function setAuthentication($username, $password)
    {
        $this->_mailer->Username = $username;
        $this->_mailer->Password = $password;

        return $this;
    }
593277
public function update_user($values, $username = null)
	{
		$username = $username ?: $this->user['username'];
		$current_values = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
			->where('username', '=', $username)
			->from(\Config::get('simpleauth.table_name'))
			->execute(\Config::get('simpleauth.db_connection'));

		if (empty($current_values))
		{
			throw new \SimpleUserUpdateException('Username not found', 4);
		}

		$update = array();
		if (array_key_exists('username', $values))
		{
			throw new \SimpleUserUpdateException('Username cannot be changed.', 5);
		}
		if (array_key_exists('password', $values))
		{
			if (empty($values['old_password'])
				or $current_values->get('password') != $this->hash_password(trim($values['old_password'])))
			{
				throw new \SimpleUserWrongPassword('Old password is invalid');
			}

			$password = trim(strval($values['password']));
			if ($password === '')
			{
				throw new \SimpleUserUpdateException('Password can\'t be empty.', 6);
			}
			$update['password'] = $this->hash_password($password);
			unset($values['password']);
		}
		if (array_key_exists('old_password', $values))
		{
			unset($values['old_password']);
		}
		if (array_key_exists('email', $values))
		{
			$email = filter_var(trim($values['email']), FILTER_VALIDATE_EMAIL);
			if ( ! $email)
			{
				throw new \SimpleUserUpdateException('Email address is not valid', 7);
			}
			$matches = \DB::select()
				->where('email', '=', $email)
				->where('id', '!=', $current_values[0]['id'])
				->from(\Config::get('simpleauth.table_name'))
				->execute(\Config::get('simpleauth.db_connection'));
			if (count($matches))
			{
				throw new \SimpleUserUpdateException('Email address is already in use', 11);
			}
			$update['email'] = $email;
			unset($values['email']);
		}
		if (array_key_exists('group', $values))
		{
			if (is_numeric($values['group']))
			{
				$update['group'] = (int) $values['group'];
			}
			unset($values['group']);
		}
		if ( ! empty($values))
		{
			$profile_fields = @unserialize($current_values->get('profile_fields')) ?: array();
			foreach ($values as $key => $val)
			{
				if ($val === null)
				{
					unset($profile_fields[$key]);
				}
				else
				{
					$profile_fields[$key] = $val;
				}
			}
			$update['profile_fields'] = serialize($profile_fields);
		}

		$update['updated_at'] = \Date::forge()->get_timestamp();

		$affected_rows = \DB::update(\Config::get('simpleauth.table_name'))
			->set($update)
			->where('username', '=', $username)
			->execute(\Config::get('simpleauth.db_connection'));

		// Refresh user
		if ($this->user['username'] == $username)
		{
			$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
				->where('username', '=', $username)
				->from(\Config::get('simpleauth.table_name'))
				->execute(\Config::get('simpleauth.db_connection'))->current();
		}

		return $affected_rows > 0;
	}
669075
function user_password($username,$password){
        if ($username==NULL){ return (false); }
        if ($password==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        if (!$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
        
        $user=$this->user_info($username,array("cn"));
        if ($user[0]["dn"]==NULL){ return (false); }
        $user_dn=$user[0]["dn"];
                
        $add=array();
        $add["unicodePwd"][0]=$this->encode_password($password);
        
        $result=ldap_mod_replace($this->_conn,$user_dn,$add);
        if ($result==false){ return (false); }
        
        return (true);
    }
1190801
public function createUser($username, $password)
    {
        // Check if user exists
        $stmt = $this->conn->prepare(sprintf("SELECT user_name FROM %s WHERE user_name = :name", $this->table));
        $stmt->execute(['name' => $username]);
        $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        // If username already exists return false.
        if (count($result) !== 0) {
            return false;
        }

        // Hash password
        $password = $this->hasher->HashPassword($password);

        // Insert into database
        $stmt = $this->conn->prepare(sprintf("INSERT INTO %s (user_name, user_pass, user_date)
                                                              VALUES (:name, :pass, now())", $this->table));
        $stmt->execute(['name' => $username, 'pass' => $password]);

        // Return success status
        if ($stmt->rowCount() === 1) {
            return $this->conn->lastInsertId();
        }
        return false;
    }
882789
public function Authenticate($username, $password)
    {
        // Start authentication
        fputs($this->smtp_conn, "AUTH LOGIN" . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 334) {
            $this->error =
            array("error" => "AUTH not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        // Send encoded username
        fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 334) {
            $this->error =
            array("error" => "Username not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        // Send encoded password
        fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 235) {
            $this->error =
            array("error" => "Password not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        return true;
    }
189154
protected function getHashedPassword($username)
	{
		$password = $this->db->setQuery(
			$this->db->getQuery(true)
				->select($this->dbOptions['password_column'])
				->from($this->dbOptions['database_table'])
				->where($this->dbOptions['username_column'] . ' = ' . $this->db->quote($username))
		)->loadResult();

		if (!$password)
		{
			return false;
		}

		return $password;
	}
270938
public function update_token($username) {
        $token = self::hash();

        $query = sprintf(self::UPDATE_VALUE,
            $this->params['table'],
            $this->params['token'],
            $this->pdo->quote($token),
            $this->params['username'],
            $this->pdo->quote($username));

        $stmt = $this->pdo->query($query);

        if($stmt === FALSE || $stmt->rowCount() !== 1) {
            throw new UserException('Token not found');
        }

        return $token;
    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
746815
def update_userpass_password(self, username, password, mount_point='userpass'):
        
        params = {
            'password': password
        }
        return self._adapter.post('/v1/auth/{}/users/{}/password'.format(mount_point, username), json=params)