diff --git a/appinfo/info.xml b/appinfo/info.xml
index 85de603..2a79e40 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -21,8 +21,8 @@
auth
-
-
+
+
\OCA\UserSQL\Settings\Admin
diff --git a/appinfo/routes.php b/appinfo/routes.php
index dde5395..46429a6 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -2,8 +2,9 @@
/**
* Nextcloud - user_sql
*
- * @copyright 2012-2015 Andreas Böhler
+ * @copyright 2025 Claus-Justus Heine
* @copyright 2018 Marcin Łojewski
+ * @copyright 2012-2015 Andreas Böhler
* @author Marcin Łojewski
*
* This program is free software: you can redistribute it and/or modify
@@ -22,50 +23,49 @@
use OCA\UserSQL\AppInfo\Application;
-$application = new Application();
-$application->registerRoutes(
- $this, [
- "routes" => [
- [
- "name" => "settings#verifyDbConnection",
- "url" => "/settings/db/verify",
- "verb" => "POST"
- ],
- [
- "name" => "settings#saveProperties",
- "url" => "/settings/properties",
- "verb" => "POST"
- ],
- [
- "name" => "settings#clearCache",
- "url" => "/settings/cache/clear",
- "verb" => "POST"
- ],
- [
- "name" => "settings#tableAutocomplete",
- "url" => "/settings/autocomplete/table",
- "verb" => "POST"
- ],
- [
- "name" => "settings#userTableAutocomplete",
- "url" => "/settings/autocomplete/table/user",
- "verb" => "POST"
- ],
- [
- "name" => "settings#userGroupTableAutocomplete",
- "url" => "/settings/autocomplete/table/user_group",
- "verb" => "POST"
- ],
- [
- "name" => "settings#groupTableAutocomplete",
- "url" => "/settings/autocomplete/table/group",
- "verb" => "POST"
- ],
- [
- "name" => "settings#cryptoParams",
- "url" => "/settings/crypto/params",
- "verb" => "GET"
- ],
- ]
- ]
-);
+$routes = [
+ 'routes' => [
+ [
+ "name" => "settings#verifyDbConnection",
+ "url" => "/settings/db/verify",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#saveProperties",
+ "url" => "/settings/properties",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#clearCache",
+ "url" => "/settings/cache/clear",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#tableAutocomplete",
+ "url" => "/settings/autocomplete/table",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#userTableAutocomplete",
+ "url" => "/settings/autocomplete/table/user",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#userGroupTableAutocomplete",
+ "url" => "/settings/autocomplete/table/user_group",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#groupTableAutocomplete",
+ "url" => "/settings/autocomplete/table/group",
+ "verb" => "POST"
+ ],
+ [
+ "name" => "settings#cryptoParams",
+ "url" => "/settings/crypto/params",
+ "verb" => "GET"
+ ],
+ ],
+];
+
+return $routes;
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index c16d2e8..578a24a 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -2,10 +2,10 @@
/**
* Nextcloud - user_sql
*
- * @copyright 2018 Marcin Łojewski
- * @author Marcin Łojewski
* @copyright 2025 Claus-Justus Heine
* @author Claus-Justus Heine
+ * @copyright 2018 Marcin Łojewski
+ * @author Marcin Łojewski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -63,8 +63,12 @@ public function boot(IBootContext $context): void
IGroupManager $groupManager,
Backend\GroupBackend $groupBackend,
) {
- $userManager->registerBackend($userBackend);
- $groupManager->addBackend($groupBackend);
+ if ($userBackend->isConfigured()) {
+ $userManager->registerBackend($userBackend);
+ }
+ if ($groupBackend->isConfigured()) {
+ $groupManager->addBackend($groupBackend);
+ }
});
}
}
diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php
index 370d45d..842c1bc 100644
--- a/lib/Backend/UserBackend.php
+++ b/lib/Backend/UserBackend.php
@@ -261,13 +261,13 @@ private function getUser($uid)
if ($user instanceof User) {
$this->cache->set($cacheKey, $user);
- // avoid recursion as the action may very well call into the UserManager again ...
- $actions = $this->actions;
- $this->actions = [];
- foreach ($this->actions as $action) {
+ // avoid recursion as the action may very well call into the UserManager again ...
+ $actions = $this->actions;
+ $this->actions = [];
+ foreach ($actions as $action) {
$action->doAction($user);
}
- $this->actions = $actions;
+ $this->actions = $actions;
}
return $user;
diff --git a/lib/Query/DataQuery.php b/lib/Query/DataQuery.php
index ea33803..4203182 100644
--- a/lib/Query/DataQuery.php
+++ b/lib/Query/DataQuery.php
@@ -4,6 +4,8 @@
*
* @copyright 2021 Marcin Łojewski
* @author Marcin Łojewski
+ * @copyright 2025 Claus-Justus Heine
+ * @author Claus-Justus Heine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -21,6 +23,8 @@
namespace OCA\UserSQL\Query;
+use UnexpectedValueException;
+
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception as DBALException;
use OC\DB\Connection;
@@ -151,6 +155,10 @@ private function connectToDatabase()
"driverOptions" => array()
);
+ if (empty($this->properties[DB::DRIVER])) {
+ throw new UnexpectedValueException('Attempt to connect without configuration.');
+ }
+
if ($this->properties[DB::DRIVER] == 'mysql') {
if ($this->properties[DB::SSL_CA]) {
$parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA];