From d205aa12971e08f4127b993df4462c230b689eba Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 1 Jan 2026 16:49:24 +0100 Subject: [PATCH] Make LoTW login test code more bullet-proof --- application/controllers/Lotw.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 90686c458..911db8d98 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -849,20 +849,17 @@ class Lotw extends CI_Controller { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $content = curl_exec($ch); - if ($content) { - if(curl_errno($ch)) { - $ret['status']='failed'; - $ret['details']== sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); - } else if (str_contains($content,"Username/password incorrect")) { + if(curl_errno($ch)) { + $ret['status']='failed'; + $ret['details'] = sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); + } else { + if (str_contains($content,"Username/password incorrect")) { $ret['status']='failed_wrong_creds'; $ret['details']= sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], __("Username/password incorrect")); } else { $ret['status']='OK'; $ret['details']= __("LoTW login OK!"); } - } else { - $ret['status']='failed_na'; - $ret['details']= __("LoTW currently not available. Try again later."); } } else { if (($ret['status'] ?? '') == '') {