Skip to content
Open
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</types>
<category>auth</category>
<dependencies>
<php min-version="8.0"/>
<nextcloud min-version="31" max-version="31"/>
<php min-version="8.4"/>
<nextcloud min-version="31" max-version="33"/>
</dependencies>
<settings>
<admin>\OCA\UserSQL\Settings\Admin</admin>
Expand Down
96 changes: 48 additions & 48 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/**
* Nextcloud - user_sql
*
* @copyright 2012-2015 Andreas Böhler <dev (at) aboehler (dot) at>
* @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de>
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @copyright 2012-2015 Andreas Böhler <dev (at) aboehler (dot) at>
* @author Marcin Łojewski <dev@mlojewski.me>
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -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;
12 changes: 8 additions & 4 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* Nextcloud - user_sql
*
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me>
* @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de>
* @author Claus-Justus Heine <himself@claus-justus-heine.de>
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -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);
}
});
}
}
10 changes: 5 additions & 5 deletions lib/Backend/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions lib/Query/DataQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* @copyright 2021 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me>
* @copyright 2025 Claus-Justus Heine
* @author Claus-Justus Heine <himself@claus-justus-heine.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down