Detect paid updates in the Plugin-Store during the process
authorAlexander Ebert <ebert@woltlab.com>
Wed, 6 Sep 2023 19:16:37 +0000 (21:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 7 Sep 2023 09:44:46 +0000 (11:44 +0200)
See https://www.woltlab.com/community/thread/296689/

wcfsetup/install/files/lib/system/package/PackageUpdateUnauthorizedException.class.php

index 9c845ef35471a71531b5261797dcb5727935e53d..64d118d7eaf1b6cebcd592ecf776800d60ff1156 100644 (file)
@@ -61,13 +61,25 @@ class PackageUpdateUnauthorizedException extends UserException
         $serverReply = $this->request->getReply();
 
         $authInsufficient = (($serverReply['httpHeaders']['wcf-update-server-auth'][0] ?? '') === 'unauthorized');
-        if (ENABLE_ENTERPRISE_MODE && $authInsufficient && !empty($this->packageUpdateVersion['pluginStoreFileID'])) {
-            WCF::getTPL()->assign([
-                'packageName' => $this->packageUpdateVersion['packageName'],
-                'pluginStoreFileID' => $this->packageUpdateVersion['pluginStoreFileID'],
-            ]);
+        if ($authInsufficient && !empty($this->packageUpdateVersion['pluginStoreFileID'])) {
+            $hasOnlyTrustedServers = true;
+            if (!ENABLE_ENTERPRISE_MODE) {
+                foreach (PackageUpdateServer::getActiveUpdateServers() as $updateServer) {
+                    if (!$updateServer->isWoltLabUpdateServer() && !$updateServer->isWoltLabStoreServer()) {
+                        $hasOnlyTrustedServers = false;
+                        break;
+                    }
+                }
+            }
 
-            return WCF::getTPL()->fetch('packageUpdateUnauthorizedPurchaseRequired');
+            if ($hasOnlyTrustedServers) {
+                WCF::getTPL()->assign([
+                    'packageName' => $this->packageUpdateVersion['packageName'],
+                    'pluginStoreFileID' => $this->packageUpdateVersion['pluginStoreFileID'],
+                ]);
+
+                return WCF::getTPL()->fetch('packageUpdateUnauthorizedPurchaseRequired');
+            }
         }
 
         WCF::getTPL()->assign([