public function changePassword($password, $write = true)
    {
        $this->Password = $password;
        $valid = $this->validate();

        $this->extend('onBeforeChangePassword', $password, $valid);

        if ($valid->isValid()) {
            $this->AutoLoginHash = null;

            $this->encryptPassword();

            if ($write) {
                $this->passwordChangesToWrite = true;
                $this->write();
            }
        }

        $this->extend('onAfterChangePassword', $password, $valid);

        return $valid;
    }