From 48ffd73884df557faf5c15bc2300946d9011cbba Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 14 Jun 2025 07:05:26 -0400 Subject: [PATCH] Data flow login fix --- application/config/config.production.php | 3 +- application/controllers/Bko.php | 4 +- application/controllers/Login.php | 106 ++++++++++++----------- 3 files changed, 62 insertions(+), 51 deletions(-) diff --git a/application/config/config.production.php b/application/config/config.production.php index dde4d82..b4b7295 100644 --- a/application/config/config.production.php +++ b/application/config/config.production.php @@ -11,4 +11,5 @@ $arr["port"] = 5432; define('LEGACY_BACKEND_ENDPOINT','backend.wrenchboard.api.live'); //define('EXTENSTION_API_URL','https://dashboard.wrenchboard.com/svs/bko'); // // define('EXTENSTION_API_URL','http://172.16.4.100:9083/svs/bko'); -define('EXTENSTION_API_URL','http://172.16.4.25:9083/svs/bko'); \ No newline at end of file +//define('EXTENSTION_API_URL','http://172.16.4.25:9083/svs/bko'); +define('EXTENSTION_API_URL','http://172.16.4.25:9083/backoffice/svs/bko'); \ No newline at end of file diff --git a/application/controllers/Bko.php b/application/controllers/Bko.php index f8a1c43..2b5d98d 100644 --- a/application/controllers/Bko.php +++ b/application/controllers/Bko.php @@ -47,6 +47,8 @@ class Bko extends CI_Controller { */ $this->populate_bko_session($res, $out); + redirect('bkouser/dash'); + exit(); } } @@ -64,7 +66,7 @@ class Bko extends CI_Controller { $_SESSION['bko_selected_memberd_id'] = 0; $_SESSION['bko_group'] = $out['group_id']; $_SESSION['bkodata'] = $out; - redirect('bkouser/dash'); + } } diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 183f68e..1f9a6af 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -14,67 +14,75 @@ class Login extends WRB_Controller { public function index() { $data["login_message"] = ""; - $this->load->library('form_validation'); - $this->form_validation->set_rules('username', 'Username', 'required'); - $this->form_validation->set_rules('password', 'Password', 'required'); - if ($this->form_validation->run() !== false) { + try { + $this->load->library('form_validation'); + $this->form_validation->set_rules('username', 'Username', 'required'); + $this->form_validation->set_rules('password', 'Password', 'required'); + + if ($this->form_validation->run() !== false) { - $data['username'] = strtolower($this->input->post('username')); // '08174596144'; - $data['password'] = $this->input->post('password'); //'7978'; + $data['username'] = strtolower($this->input->post('username')); // '08174596144'; + $data['password'] = $this->input->post('password'); //'7978'; - $data['sessionid'] = rand(10000, 99999) . "A" . rand(10000, 99999); - $data['action'] = WRENCHBOARD_ACCOUNT_LOGIN; - $this->load->model('backend_model'); - $out = array(); - // $res = $this->backend_model->wrenchboard_api($data, $out); - $res = $this->wrenchboard_api($data, $out); - $is_live = $this->backend_model->cfgReadChar("system.live"); + $data['sessionid'] = rand(10000, 99999) . "A" . rand(10000, 99999); + $data['action'] = WRENCHBOARD_ACCOUNT_LOGIN; + $this->load->model('backend_model'); + $out = array(); + // $res = $this->backend_model->wrenchboard_api($data, $out); + $res = $this->wrenchboard_api($data, $out); + $is_live = $this->backend_model->cfgReadChar("system.live"); - // var_dump($out); - // print_r($out); - if ($res == PHP_LOGIN_OK) { - $this->load->model('account_model'); - $ret = $this->account_model->username_data($data); - if ($res !== false) { - $data["login_message"] = "Welcome..."; - // yes person has an account - $_SESSION['session_id'] = $out["session"]; - $_SESSION['username'] = $this->input->post('username'); - $_SESSION['name'] = $this->input->post('username'); - $_SESSION['firstname'] = $ret->firstname; - $_SESSION['lastname'] = $ret->lastname; - $_SESSION['email'] = $ret->email; - $_SESSION['member_id'] = $ret->id; - $_SESSION['log_count'] = 0; - $_SESSION['mesaage_count'] = 0; - $this->findOffers($_SESSION['email']); - $_SESSION['message_snapshot'] = $this->myMessagesSnapshot(); - $_SESSION['total_jobs'] = 0; - if (trim($ret->profile_pic) == '') { - // Show default picture - $_SESSION['profile_picture'] = "../smedia/DEFAULTS/default-profile.png"; - } else { - // show the profile picture - $_SESSION['profile_picture'] = "../smedia/" . ($is_live ? "LIVE" : "TEST") . "/profile/" . $ret->profile_pic; + + // print_r($out); + if ($res == PHP_LOGIN_OK) { + $this->load->model('account_model'); + $ret = $this->account_model->username_data($data); + if ($res !== false) { + $data["login_message"] = "Welcome..."; + // yes person has an account + $_SESSION['session_id'] = $out["session"]; + $_SESSION['username'] = $this->input->post('username'); + $_SESSION['name'] = $this->input->post('username'); + $_SESSION['firstname'] = $ret->firstname; + $_SESSION['lastname'] = $ret->lastname; + $_SESSION['email'] = $ret->email; + $_SESSION['member_id'] = $ret->id; + $_SESSION['log_count'] = 0; + $_SESSION['mesaage_count'] = 0; + $this->findOffers($_SESSION['email']); + $_SESSION['message_snapshot'] = $this->myMessagesSnapshot(); + $_SESSION['total_jobs'] = 0; + if (trim($ret->profile_pic) == '') { + // Show default picture + $_SESSION['profile_picture'] = "../smedia/DEFAULTS/default-profile.png"; + } else { + // show the profile picture + $_SESSION['profile_picture'] = "../smedia/" . ($is_live ? "LIVE" : "TEST") . "/profile/" . $ret->profile_pic; + } + + + $this->logUser('Account login'); + $this->refreshAccountDetail($_SESSION['member_id']); + $this->getSessionArray(); + redirect('dash'); } - - - $this->logUser('Account login'); - $this->refreshAccountDetail($_SESSION['member_id']); - $this->getSessionArray(); - redirect('dash'); + } else { + $data["login_message"] = "Invalid username or password"; } + + $res = false; // $this->login_model->verify_login($data); } else { - $data["login_message"] = "Invalid username or password"; + echo validation_errors(); } - $res = false; // $this->login_model->verify_login($data); - } else { - echo validation_errors(); + + } catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; } + if ($this->lib_login->is_authenticated()) {