diff --git a/app/Controllers/DigiFiAuth.php b/app/Controllers/DigiFiAuth.php index b83fee0..e7a18d7 100644 --- a/app/Controllers/DigiFiAuth.php +++ b/app/Controllers/DigiFiAuth.php @@ -34,10 +34,27 @@ class DigiFiAuth extends BaseController public function startBkoToken() { $data = $this->request->getPost(); + if ( $data['username'] == '' || $data['pass'] == '' ){ + return $this->fail([] , 409); + } - if ( $data['username'] == 'demo@demo.com' && $data['pass']=== 'demo1' ){ + $username = $data['username']; + $pass = $data['pass']; + $sqlC = "SELECT * FROM bko_users WHERE username ='".$username."' AND pass = md5('".$pass."')"; + $query = $this->db->query($sqlC); + $resV = $query->getResultArray(); + $results = []; + if (count($resV)> 0){ + $results = $resV[0]; + } - $final_out = $data; + // var_dump($results); + + if ( count($results) > 0 + && $results['uid'] != '' + && $results['updated'] != '' ){ + + $final_out = $results; $key = getenv('JWT_SECRET'); $iat = time(); // current timestamp value @@ -60,12 +77,12 @@ class DigiFiAuth extends BaseController 'username' => $data['username'], 'token' => $token, "id" => 1, - "first_name" => "Biboqwe", - "last_name" => "Fotoohi", - "email" => "demo@demo.com", + "first_name" => $results['firstname'], + "last_name" => $results['lastname'], + "email" => $results['email'], "email_verified_at" => "2023-07-12T13:39:04.000000Z", - "created_at" => "2023-07-12T13:39:04.000000Z", - "updated_at" => "2024-04-01T21:01:31.000000Z", + "created_at" => $results['added'], + "updated_at" => $results['updated'], "api_token" => $token ];