-
+
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]; }