settings fix
This commit is contained in:
1 parent
849aec84d4
commit
fe93a0f80e
2 files changed
+10
-8
No files matched your search
+3
-3
@@ -1037,10 +1037,10 @@ if (str_starts_with($route, '/api/')) {
|
||||
<button id="caldav-close" class="flex items-center gap-1.5 px-2.5 py-1 text-xs border border-t-border text-t-muted hover:border-t-danger hover:text-t-danger transition-colors"><i class="ph ph-x text-sm"></i><span class="font-pixel text-[10px]">close</span></button>
|
||||
</div>
|
||||
<div class="p-5 space-y-3">
|
||||
<div><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">server url</label><input id="caldav-url" type="text" placeholder="https://cloud.example.com/remote.php/dav/calendars/user/personal/" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none placeholder:text-t-dim font-mono"></div>
|
||||
<div><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">server url</label><input id="caldav-url" type="text" placeholder="https://cloud.example.com/remote.php/dav/calendars/user/personal/" autocomplete="off" data-1p-ignore data-lpignore="true" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none placeholder:text-t-dim font-mono"></div>
|
||||
<div class="flex gap-3">
|
||||
<div class="flex-1"><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">username</label><input id="caldav-user" type="text" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none font-mono"></div>
|
||||
<div class="flex-1"><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">password</label><input id="caldav-pass" type="password" placeholder="app password" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none font-mono"></div>
|
||||
<div class="flex-1"><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">username</label><input id="caldav-user" type="text" autocomplete="off" data-1p-ignore data-lpignore="true" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none font-mono"></div>
|
||||
<div class="flex-1"><label class="font-pixel text-[9px] text-t-dim uppercase block mb-1">password</label><input id="caldav-pass" type="password" placeholder="app password" autocomplete="new-password" data-1p-ignore data-lpignore="true" class="w-full bg-t-bg border border-t-border text-t-bright px-3 py-2 text-xs focus:border-t-accent focus:outline-none font-mono"></div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button id="caldav-test" class="flex items-center gap-1.5 px-3 py-1.5 text-xs border border-t-border text-t-muted hover:border-t-accent hover:text-t-accent transition-colors"><i class="ph ph-plugs-connected text-sm"></i><span class="font-pixel text-[10px]">test</span></button>
|
||||
|
||||
+7
-5
@@ -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]; }
|
||||
|
||||
Reference in new issue
Block a user