From 577995cf03b678f78e7d9edd1b1f6cb4da772158 Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Sun, 10 Apr 2022 19:04:17 -0400 Subject: [PATCH] fix --- www/application/controllers/Jobs.php | 5 +++ www/application/controllers/Login.php | 36 ++++++++++++++------ www/application/models/Combo_model.php | 27 +++++++++++---- www/application/views/jobs/view_create.php | 5 +-- www/application/views/users/view_profile.php | 6 ++-- 5 files changed, 54 insertions(+), 25 deletions(-) diff --git a/www/application/controllers/Jobs.php b/www/application/controllers/Jobs.php index 96e25f39..408f2638 100644 --- a/www/application/controllers/Jobs.php +++ b/www/application/controllers/Jobs.php @@ -917,6 +917,7 @@ echo $this->getMarketInterestMessage( $data['offer_code'], $out['client_id'] ) $description = NULL; $job_detail = NULL; $timeline = NULL; + $country = 'NG'; // $timeline_days = NULL; $price = NULL; $submit = NULL; @@ -954,6 +955,10 @@ echo $this->getMarketInterestMessage( $data['offer_code'], $out['client_id'] ) } + $this->load->model('combo_model'); + $this->combo_model->defaultComboMessage = 'Select Job Country'; + $data['country_job'] = $this->combo_model->getCountryJobCombo('country', $country); + if ($redirected == false) { $this->load->model('dash_model'); $out = $this->dash_model->getDashData($data); diff --git a/www/application/controllers/Login.php b/www/application/controllers/Login.php index 41d3e0ae..a4f035d7 100644 --- a/www/application/controllers/Login.php +++ b/www/application/controllers/Login.php @@ -36,7 +36,7 @@ class Login extends WRB_Controller { } public function index() { - $data["login_message"] = ""; + $data["login_message"] = $this->session->flashdata('login_message'); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); @@ -100,6 +100,7 @@ class Login extends WRB_Controller { $fb_data = $this->lib_login->getData($this->lib_login->get_access_token()); if (isset($fb_data['me'])) { $user = $fb_data['me']; + $user['facebook'] = 1; list($proceed, $data) = $this->checkUserExists($user, $data); @@ -133,7 +134,7 @@ class Login extends WRB_Controller { $_SESSION['mesaage_count'] = 0; $this->findOffers($_SESSION['email']); $_SESSION['message_snapshot'] = $this->myMessagesSnapshot(); - + $_SESSION['profile_picture'] = "../smedia/DEFAULTS/default-profile.png"; $this->logUser('Account login'); $this->refreshAccountDetail($_SESSION['member_id']); $this->getSessionArray(); @@ -194,8 +195,12 @@ class Login extends WRB_Controller { private function checkUserExists($user, $data) { $proceed = false; + $q = " AND external_idp_provider=1"; + if (is_array($user) && array_key_exists('google',$user)) { + $q = " AND external_idp_provider=2"; + } //$data["login_message"] = $user["id"]."/".$user["name"]."/".$user["email"]."Logout"; - $q = "SELECT * FROM members WHERE lower(email)=lower('" . $user["name"] . "') AND password IS NULL AND fb_id='" . $user["id"] . "'"; + $q = "SELECT * FROM members WHERE lower(email)=lower('" . $user["name"] . "') AND password IS NULL AND external_idp_provider_id='" . $user["id"] . "'" . $q; $query = $this->db->query($q); if (count($query->result_array)) { // Account exists @@ -245,7 +250,8 @@ class Login extends WRB_Controller { $user = array( 'id' => $id, 'name' => $name, - 'email' => $email + 'email' => $email, + 'google' => 1 ); list($proceed, $data) = $this->checkUserExists($user, $data); @@ -264,11 +270,6 @@ class Login extends WRB_Controller { $this->load->model('backend_model'); $out = array(); - echo "
";
-                        var_dump($data);
-                        exit();
-                        /*    
-                        // TODO
                         $res = $this->backend_model->wrenchboard_api($data, $out);
                         if ($res == PHP_LOGIN_OK) {
                             $this->load->model('account_model');
@@ -287,7 +288,7 @@ class Login extends WRB_Controller {
                                 $_SESSION['mesaage_count'] = 0;
                                 $this->findOffers($_SESSION['email']);
                                 $_SESSION['message_snapshot'] = $this->myMessagesSnapshot();
-
+                                $_SESSION['profile_picture'] = "../smedia/DEFAULTS/default-profile.png";
                                 $this->logUser('Account login');
                                 $this->refreshAccountDetail($_SESSION['member_id']);
                                 $this->getSessionArray();
@@ -295,23 +296,36 @@ class Login extends WRB_Controller {
                                 $this->excudedEmails();
 
                                 redirect('dash');
+                            } else {
+                                // Cannot proceed - account model error?
+                                $this->session->set_flashdata('login_message','Cannot proceed - account model error: '.$ret);
+                                redirect('login');
                             }
+                        } else {
+                            // Cannot proceed - backend error?
+                            $msg = (is_array($out) && array_key_exists('status',$out) && $out['status']!='') 
+                                ? $out ['status'] : json_encode($out);
+                            $this->session->set_flashdata('login_message','Cannot proceed - backend error: '.$msg);
+                            redirect('login');
                         }
-                        //*/
                     } else {
                         // Cannot proceed - duplicate email?
+                        $this->session->set_flashdata('login_message','Cannot proceed - duplicate email');
                         redirect('login');
                     }
                 } else {
                     // Invalid or missing id and/or email - login failed?
+                    $this->session->set_flashdata('login_message','Invalid or missing id and/or email - login failed!');
                     redirect('login');
                 }
             } else {
                 // Missing access token / invalid grant - expired credentials?
+                $this->session->set_flashdata('login_message','Missing access token / invalid grant - expired credentials!');
                 redirect('login');
             }
         } else {
             // Invalid or missing code - login failed?
+            $this->session->set_flashdata('login_message','Invalid or missing code - login failed!');
             redirect('login');
         }      
     }
diff --git a/www/application/models/Combo_model.php b/www/application/models/Combo_model.php
index 7a056c97..5c6ce80a 100644
--- a/www/application/models/Combo_model.php
+++ b/www/application/models/Combo_model.php
@@ -22,7 +22,7 @@ class Combo_model extends CI_Model {
         }
 
         for ($ii = 2; $ii <= 5; $ii++) {
-$days_c = $ii*7;
+            $days_c = $ii*7;
             $cmbstr .= "";
         }
         return $this->comboFrame($option_name,  $cmbstr);
@@ -105,6 +105,19 @@ $days_c = $ii*7;
         return $this->comboFrame($option_name, $option_value);
     }
 
+    public function getCountryJobCombo($option_name, $curVal) {
+        $q = $this
+            ->db
+            ->where('status', 1)
+            ->where('jobs is NOT NULL', NULL, FALSE)
+            ->order_by('country', 'ASC')
+            ->get('country');
+
+        $option_value = $this->optionValueObject($q->result(), "code", "country", $curVal);
+
+        return $this->comboFrame($option_name, $option_value);
+    }
+
     public function getBankCombo($option_name, $curVal) {
         /*
           wrenchboard=> Select code,name from bank_entity_codes WHERE country ='NG' ORDER BY name ASC;
@@ -148,12 +161,12 @@ $days_c = $ii*7;
     }
 
     private function comboFrame($option_name, $option_value) {
-        $addReaOnly = "";
-        if ($this->readOnlyMode == true) {
-            $addReaOnly = " disabled ";
-        }
-
-        return $cmb = "";
+            $addReaOnly = "";
+            if ($this->readOnlyMode == true) {
+                $addReaOnly = " disabled ";
+            }
+            $style_line = "form-select form-select-solid form-select-lg";
+        return $cmb = "";
     }
 
 }
diff --git a/www/application/views/jobs/view_create.php b/www/application/views/jobs/view_create.php
index e6248e85..1aff63ac 100644
--- a/www/application/views/jobs/view_create.php
+++ b/www/application/views/jobs/view_create.php
@@ -32,10 +32,7 @@
                                         
                                         
                                         
-                                        
+                                           
                                         
                                         
diff --git a/www/application/views/users/view_profile.php b/www/application/views/users/view_profile.php index 0b537643..e78d0abe 100644 --- a/www/application/views/users/view_profile.php +++ b/www/application/views/users/view_profile.php @@ -28,7 +28,7 @@
-
+
@@ -49,7 +49,7 @@
- +
@@ -132,7 +132,7 @@ -
+