You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
* @author Robert Strutts
|
|
* @copyright (c) 2026, Robert Strutts
|
|
* @license MIT
|
|
*/
|
|
namespace Project\Controllers\Data;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Project\Classes\BaseController;
|
|
use Project\Classes\Logic;
|
|
|
|
/**
|
|
* Description of RegPostController
|
|
* Takes and handles User Registration Post Data
|
|
*
|
|
* @author Robert Strutts
|
|
*/
|
|
class RegPostController extends BaseController
|
|
{
|
|
public function init()
|
|
{
|
|
// INIT DB CONFIGS and SERVICES!!!
|
|
\IOcornerstone\InitMainDB::doInit();
|
|
}
|
|
|
|
public function Save(): ResponseInterface
|
|
{
|
|
|
|
// Read raw JSON body
|
|
$json = file_get_contents("php://input");
|
|
// Convert JSON into PHP array
|
|
$arrayOfPost = json_decode($json, true);
|
|
$_POST = array_merge($arrayOfPost, $_POST);
|
|
|
|
$err = Logic\RegPostLogic::DoSave();
|
|
$success = $err['success'] ?? false;
|
|
if ($success === true) {
|
|
return $this->returnResponse(["success"=>true]);
|
|
}
|
|
if (count($err)) {
|
|
return $this->returnResponse(['errors'=>$err], 501);
|
|
}
|
|
return $this->returnResponse(["success" => false, "message"=>"Bad data"], 502);
|
|
}
|
|
}
|
|
|