This commit is contained in:
2023-01-28 10:25:35 -05:00
parent f3be271ebd
commit 09ddf68c75
4 changed files with 98 additions and 13 deletions
+25 -6
View File
@@ -32,10 +32,11 @@ class Myfituser extends BaseController
public function users()
{
header('Access-Control-Allow-Origin: * ');
header('Access-Control-Allow-Origin: *');
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
header('Access-Control-Allow-Credentials: true ');
//header('Access-Control-Allow-Credentials: true ');
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
header('Content-type: application/json');
@@ -52,24 +53,42 @@ class Myfituser extends BaseController
'login' => ['POST'],
];
// $raw_array = [];
$res1 = [];
if (array_key_exists($endpoint, $endpoints)) {
} else {
http_response_code(404);
// tell the user product does not exist
echo json_encode(['message' => 'Enpoint not found.']);
echo json_encode(['message' => 'Endpoint not found.']);
}
// echo "EXYTACT INPUT DATA HERE";
$raw_json = file_get_contents('php://input');
$raw_array = json_decode($raw_json, true);
switch ($endpoint) {
case "login":
$userAccess = new \App\Models\userAccess();
$res1 = $userAccess->startLogin($raw_array);
break;
case "createuser":
$res= $this->dummyData($raw_array);
break;
case 2:
echo "i equals 2";
break;
}
$userAccess = new \App\Models\userAccess();
$res1 = $userAccess->startLogin($raw_array);
return $this->response->setJson($res1);
}
//this is dummy function to establish the endpoints before real implementations
private function dummyData($raw_array){
return [
'msg'=> 'Not implemented yet',
'raw_data' => $raw_array
];
}
public function blogdata()
{
/* header("Access-Control-Allow-Origin: *");