From cef10f70e19f167ce50d5322b50b1ae30f28763b Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 28 Apr 2026 07:40:22 +0530 Subject: [PATCH] Reflect actual HealthPlix fetch secret save state --- app/Controllers/Setting/HealthplixSettings.php | 4 ++++ .../Setting/Admin/healthplix_settings.php | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Controllers/Setting/HealthplixSettings.php b/app/Controllers/Setting/HealthplixSettings.php index f147515..7efb724 100644 --- a/app/Controllers/Setting/HealthplixSettings.php +++ b/app/Controllers/Setting/HealthplixSettings.php @@ -82,9 +82,13 @@ class HealthplixSettings extends BaseController ]); } + $storedFetchSecret = $this->readSettingValue('HEALTHPLIX_FETCH_SECRET'); + return $this->response->setJSON([ 'update' => 1, 'error_text' => 'Saved ' . $savedCount . ' setting(s)', + 'healthplixFetchSecretConfigured' => $storedFetchSecret !== '', + 'healthplixFetchSecretMasked' => $this->maskKey($storedFetchSecret), 'csrfName' => csrf_token(), 'csrfHash' => csrf_hash(), ]); diff --git a/app/Views/Setting/Admin/healthplix_settings.php b/app/Views/Setting/Admin/healthplix_settings.php index 4905e96..079886e 100644 --- a/app/Views/Setting/Admin/healthplix_settings.php +++ b/app/Views/Setting/Admin/healthplix_settings.php @@ -136,6 +136,16 @@ $('#healthplix_settings_msg').html('
' + $('
').text(text || '').html() + '
'); } + function updateFetchSecretHintFromServer(data) { + if (data && data.healthplixFetchSecretConfigured) { + var maskedSecret = data.healthplixFetchSecretMasked || '********'; + $('#healthplix_fetch_secret_hint').html('✓ Secret saved (' + $('
').text(maskedSecret).html() + '). Leave blank to keep existing.'); + return; + } + + $('#healthplix_fetch_secret_hint').html('No callback secret configured yet.'); + } + function postJson(url, payload, cb) { var csrf = getCsrfPair(); payload = payload || {}; @@ -203,13 +213,7 @@ $('#healthplix_tenant_key_hint').html('Leave blank to keep existing key.'); } - var savedSecret = ($('#healthplix_fetch_secret').val() || '').trim(); - if (savedSecret.length > 0) { - var maskedSecret = savedSecret.length <= 8 ? '********' : (savedSecret.substring(0, 4) + '****' + savedSecret.slice(-4)); - $('#healthplix_fetch_secret_hint').html('✓ Secret saved (' + maskedSecret + '). Leave blank to keep existing.'); - } else { - $('#healthplix_fetch_secret_hint').html('Leave blank to keep existing callback secret.'); - } + updateFetchSecretHintFromServer(data); $('#healthplix_tenant_key').val(''); $('#healthplix_fetch_secret').val('');