|
11 | 11 | namespace OCA\UserOIDC\Service; |
12 | 12 |
|
13 | 13 | use OCA\UserOIDC\AppInfo\Application; |
| 14 | +use OCP\Exceptions\AppConfigTypeConflictException; |
14 | 15 | use OCP\IAppConfig; |
| 16 | +use Psr\Log\LoggerInterface; |
15 | 17 |
|
16 | 18 | class SettingsService { |
17 | 19 |
|
18 | 20 | public function __construct( |
19 | 21 | private IAppConfig $appConfig, |
| 22 | + private LoggerInterface $logger, |
20 | 23 | ) { |
21 | 24 | } |
22 | 25 |
|
23 | 26 | public function getAllowMultipleUserBackEnds(): bool { |
24 | | - return $this->appConfig->getValueString(Application::APP_ID, 'allow_multiple_user_backends', '1') === '1'; |
| 27 | + try { |
| 28 | + return $this->appConfig->getValueString(Application::APP_ID, 'allow_multiple_user_backends', '1') === '1'; |
| 29 | + } catch (AppConfigTypeConflictException $e) { |
| 30 | + $this->logger->warning('Incorrect app config type when getting "allow_multiple_user_backends"', ['exception' => $e]); |
| 31 | + return true; |
| 32 | + } |
25 | 33 | } |
26 | 34 |
|
27 | 35 | public function setAllowMultipleUserBackEnds(bool $value): void { |
28 | | - $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); |
| 36 | + try { |
| 37 | + $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); |
| 38 | + } catch (AppConfigTypeConflictException $e) { |
| 39 | + $this->logger->warning('Incorrect app config type when setting "allow_multiple_user_backends"', ['exception' => $e]); |
| 40 | + $this->appConfig->deleteKey(Application::APP_ID, 'allow_multiple_user_backends'); |
| 41 | + $this->appConfig->setValueString(Application::APP_ID, 'allow_multiple_user_backends', $value ? '1' : '0'); |
| 42 | + } |
29 | 43 | } |
30 | 44 | } |
0 commit comments