From fe93a0f80e215c9da84eb84b9fe9a37fde52ede7 Mon Sep 17 00:00:00 2001 From: th Date: Wed, 8 Apr 2026 14:41:45 +0200 Subject: [PATCH] settings fix --- public/index.php | 6 +++--- src/CalDavSync.php | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/public/index.php b/public/index.php index 49b5ff1..6c7d969 100644 --- a/public/index.php +++ b/public/index.php @@ -1037,10 +1037,10 @@ if (str_starts_with($route, '/api/')) {
-
+
-
-
+
+
diff --git a/src/CalDavSync.php b/src/CalDavSync.php index 9f46d49..8a1299a 100644 --- a/src/CalDavSync.php +++ b/src/CalDavSync.php @@ -54,10 +54,12 @@ class CalDavSync public function getSettings(): array { + $url = $this->getSetting('url') ? $this->decrypt($this->getSetting('url')) : ''; + $user = $this->getSetting('username') ? $this->decrypt($this->getSetting('username')) : ''; return [ 'enabled' => $this->getSetting('enabled') === '1', - 'url' => $this->getSetting('url') ? $this->decrypt($this->getSetting('url')) : '', - 'username' => $this->getSetting('username') ? $this->decrypt($this->getSetting('username')) : '', + 'url' => $url, + 'username' => $user, 'has_password' => !empty($this->getSetting('password')), 'calendar' => $this->getSetting('calendar') ?? '', 'last_sync' => $this->getSetting('last_sync') ?? '', @@ -66,8 +68,8 @@ class CalDavSync public function saveSettings(array $input): void { - if (isset($input['url'])) $this->setSetting('url', $this->encrypt($input['url'])); - if (isset($input['username'])) $this->setSetting('username', $this->encrypt($input['username'])); + if (!empty($input['url'])) $this->setSetting('url', $this->encrypt($input['url'])); + if (!empty($input['username'])) $this->setSetting('username', $this->encrypt($input['username'])); if (!empty($input['password'])) $this->setSetting('password', $this->encrypt($input['password'])); if (isset($input['calendar'])) $this->setSetting('calendar', $input['calendar']); if (isset($input['enabled'])) $this->setSetting('enabled', $input['enabled'] ? '1' : '0'); @@ -96,7 +98,7 @@ class CalDavSync $resolvedPass = $pass ?? ($this->getSetting('password') ? $this->decrypt($this->getSetting('password')) : ''); $log[] = 'URL: ' . preg_replace('#(https?://)[^@/]+:[^@/]+@#', '$1***:***@', $resolvedUrl); - $log[] = 'User: ' . $resolvedUser; + $log[] = 'User: ' . substr($resolvedUser, 0, 3) . '***'; if (!$resolvedUrl) { $log[] = 'ERROR: no URL configured'; return ['ok' => false, 'error' => 'no URL', 'log' => $log]; } if (!$resolvedUser) { $log[] = 'ERROR: no username'; return ['ok' => false, 'error' => 'no username', 'log' => $log]; }