From 472fbd2e6479237e3ff7448195ea95746808c77d Mon Sep 17 00:00:00 2001 From: dev-chiefworks Date: Sat, 2 Apr 2022 21:45:24 -0400 Subject: [PATCH] Log in fx --- app/Controllers/Savvy.php | 11 +++++++---- app/Services/FloatLogin.php | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Controllers/Savvy.php b/app/Controllers/Savvy.php index 67570e7..32a75c0 100644 --- a/app/Controllers/Savvy.php +++ b/app/Controllers/Savvy.php @@ -111,9 +111,9 @@ class Savvy extends BaseController log_message('critical', "API-WAS CALLED user 009" ); - // log_message('critical', json_encode($in) ); - // log_message('critical', json_encode($_POST) ); - + log_message('critical', json_encode($in) ); + log_message('critical', json_encode($_POST) ); + $inx = $_POST; switch ($endpoint) { case 'getdrycleanservicelist': $in["action"] = SAVVYEXT_USER_DRYCLIST; break; @@ -124,7 +124,10 @@ class Savvy extends BaseController $in["loc"] = $_SERVER["REMOTE_ADDR"]; break; case 'userlogin': $in["action"] = SAVVYEXT_USER_LOGIN; - $res = FloatLogin::floatLoginUser(); + + //{"username":"ses66181@gmail.com","password":"12345678","sessionid":"DUMMYSESSION","loc":"172.24.0.1","pid":100} + + $res = FloatLogin::floatLoginUser($inx['username'], $inx['password']); if (!empty($res)){ $data = json_decode($res, TRUE); diff --git a/app/Services/FloatLogin.php b/app/Services/FloatLogin.php index cd8bd96..9d130bf 100644 --- a/app/Services/FloatLogin.php +++ b/app/Services/FloatLogin.php @@ -6,8 +6,12 @@ use GuzzleHttp\Client as HTTPClient; class FloatLogin { - public static function floatLoginUser() + public static function floatLoginUser($username,$password) { +// {\"username\":\"test@float.sg\",\"password\":\"111111\",\"sessionid\":\"DUMMYSESSION\"}"); +// "{'username':'$username','password':'$password',\"sessionid\":\"DUMMYSESSION\"}" + +log_message('critical', "{'username':'$username','password':'$password',\"sessionid\":\"DUMMYSESSION\"}" ); // Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/ $ch = curl_init(); @@ -15,7 +19,8 @@ class FloatLogin curl_setopt($ch, CURLOPT_URL, 'http://10.20.30.26:8000/api/v1/user/login'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"username\":\"test@float.sg\",\"password\":\"111111\",\"sessionid\":\"DUMMYSESSION\"}"); + // curl_setopt($ch, CURLOPT_POSTFIELDS, "{'username':'$username','password':'$password',\"sessionid\":\"DUMMYSESSION\"}"); + curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"username\":\"$username\",\"password\":\"$password\",\"sessionid\":\"DUMMYSESSION\"}"); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); $headers = array();