]> source.dussan.org Git - nextcloud-server.git/commitdiff
unset ldap provider when disabling user_ldap 27732/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 30 Jun 2021 13:16:42 +0000 (15:16 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 30 Jun 2021 13:25:00 +0000 (15:25 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/appinfo/info.xml
apps/user_ldap/composer/composer/autoload_classmap.php
apps/user_ldap/composer/composer/autoload_static.php
apps/user_ldap/lib/Migration/UnsetDefaultProvider.php [new file with mode: 0644]

index 94cc9a2aee41f1b53e3065bc548a07230226dae7..99d35ae5d8f58eef8313af28d552ff19fa22e242 100644 (file)
@@ -37,6 +37,9 @@ A user logs into Nextcloud with their LDAP or AD credentials, and is granted acc
                <install>
                        <step>OCA\User_LDAP\Migration\SetDefaultProvider</step>
                </install>
+               <uninstall>
+                       <step>OCA\User_LDAP\Migration\UnsetDefaultProvider</step>
+               </uninstall>
                <post-migration>
                        <step>OCA\User_LDAP\Migration\UUIDFixInsert</step>
                        <step>OCA\User_LDAP\Migration\RemoveRefreshTime</step>
index 45af1123b57411845e549ea793c74af5ff185bb7..34f17532e5b8812d9dfe664d4ac5e55a882b64df 100644 (file)
@@ -59,6 +59,7 @@ return array(
     'OCA\\User_LDAP\\Migration\\UUIDFixGroup' => $baseDir . '/../lib/Migration/UUIDFixGroup.php',
     'OCA\\User_LDAP\\Migration\\UUIDFixInsert' => $baseDir . '/../lib/Migration/UUIDFixInsert.php',
     'OCA\\User_LDAP\\Migration\\UUIDFixUser' => $baseDir . '/../lib/Migration/UUIDFixUser.php',
+    'OCA\\User_LDAP\\Migration\\UnsetDefaultProvider' => $baseDir . '/../lib/Migration/UnsetDefaultProvider.php',
     'OCA\\User_LDAP\\Migration\\Version1010Date20200630192842' => $baseDir . '/../lib/Migration/Version1010Date20200630192842.php',
     'OCA\\User_LDAP\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
     'OCA\\User_LDAP\\PagedResults\\IAdapter' => $baseDir . '/../lib/PagedResults/IAdapter.php',
index bf95d3a5a03dafb046b3d3e46cc1633b22d6bac0..1973a8b31837bd5998ed1a66837006880f29394b 100644 (file)
@@ -74,6 +74,7 @@ class ComposerStaticInitUser_LDAP
         'OCA\\User_LDAP\\Migration\\UUIDFixGroup' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixGroup.php',
         'OCA\\User_LDAP\\Migration\\UUIDFixInsert' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixInsert.php',
         'OCA\\User_LDAP\\Migration\\UUIDFixUser' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixUser.php',
+        'OCA\\User_LDAP\\Migration\\UnsetDefaultProvider' => __DIR__ . '/..' . '/../lib/Migration/UnsetDefaultProvider.php',
         'OCA\\User_LDAP\\Migration\\Version1010Date20200630192842' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630192842.php',
         'OCA\\User_LDAP\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
         'OCA\\User_LDAP\\PagedResults\\IAdapter' => __DIR__ . '/..' . '/../lib/PagedResults/IAdapter.php',
diff --git a/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php b/apps/user_ldap/lib/Migration/UnsetDefaultProvider.php
new file mode 100644 (file)
index 0000000..a696b81
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\User_LDAP\Migration;
+
+use OCA\User_LDAP\LDAPProviderFactory;
+use OCP\IConfig;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+
+class UnsetDefaultProvider implements IRepairStep {
+
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IConfig $config) {
+               $this->config = $config;
+       }
+
+       public function getName(): string {
+               return 'Unset default LDAP provider';
+       }
+
+       public function run(IOutput $output): void {
+               $current = $this->config->getSystemValue('ldapProviderFactory', null);
+               if ($current === LDAPProviderFactory::class) {
+                       $this->config->deleteSystemValue('ldapProviderFactory');
+               }
+       }
+}