From edb5458f54d4c62258b570eb0f826a5677a6bbe6 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 12 Jan 2024 13:05:24 +0100 Subject: [PATCH] Ensure user records always have salt value --- application/models/Admins_model.php | 4 ++++ application/models/Providers_model.php | 24 ++++++++++++++++++++++++ application/models/Secretaries_model.php | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index 90dbdccf..8fe7d650 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -334,6 +334,10 @@ class Admins_model extends EA_Model throw new RuntimeException('No settings record found for admin with ID: ' . $admin['id']); } + if (empty($existing_settings['salt'])) { + $existing_settings['salt'] = $settings['salt'] = generate_salt(); + } + $settings['password'] = hash_password($existing_settings['salt'], $settings['password']); } diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 3a3de408..92918841 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -374,6 +374,10 @@ class Providers_model extends EA_Model throw new RuntimeException('No settings record found for provider with ID: ' . $provider['id']); } + if (empty($existing_settings['salt'])) { + $existing_settings['salt'] = $settings['salt'] = generate_salt(); + } + $settings['password'] = hash_password($existing_settings['salt'], $settings['password']); } @@ -899,6 +903,26 @@ class Providers_model extends EA_Model $decoded_resource['settings']['google_token'] = $provider['settings']['googleToken']; } + if (array_key_exists('caldavSync', $provider['settings'])) { + $decoded_resource['settings']['caldav_sync'] = $provider['settings']['caldavSync']; + } + + if (array_key_exists('caldavUrl', $provider['settings'])) { + $decoded_resource['settings']['caldav_url'] = $provider['settings']['caldavUrl']; + } + + if (array_key_exists('caldavUsername', $provider['settings'])) { + $decoded_resource['settings']['caldav_username'] = $provider['settings']['caldavUsername']; + } + + if (array_key_exists('caldavPassword', $provider['settings'])) { + $decoded_resource['settings']['caldav_password'] = $provider['settings']['caldavPassword']; + } + + if (array_key_exists('caldavCalendar', $provider['settings'])) { + $decoded_resource['settings']['caldav_calendar'] = $provider['settings']['caldavCalendar']; + } + if (array_key_exists('syncFutureDays', $provider['settings'])) { $decoded_resource['settings']['sync_future_days'] = $provider['settings']['syncFutureDays']; } diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 39e7db0c..33502e44 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -364,6 +364,10 @@ class Secretaries_model extends EA_Model throw new RuntimeException('No settings record found for secretary with ID: ' . $secretary['id']); } + if (empty($existing_settings['salt'])) { + $existing_settings['salt'] = $settings['salt'] = generate_salt(); + } + $settings['password'] = hash_password($existing_settings['salt'], $settings['password']); }