diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/server/App/App.php b/server/App/App.php old mode 100644 new mode 100755 diff --git a/server/App/routes_map.php b/server/App/routes_map.php old mode 100644 new mode 100755 index 20870e3..99d39b0 --- a/server/App/routes_map.php +++ b/server/App/routes_map.php @@ -10,11 +10,15 @@ $auth = new Auth(); if($auth -> user_name_is_exists($uname)) { - return error("signup", "User name already exists"); + return error_response("signup", "User name already exists"); } - $auth -> signup($uname, $password); + $user_id = $auth -> signup($uname, $password); - return + if(!$user_id) { + return error_response("signup", "Unknown error"); + } + + return success_reponse("signup", ["status" => true]); }); } \ No newline at end of file diff --git a/server/Kernel/Classes/Auth.php b/server/Kernel/Classes/Auth.php old mode 100644 new mode 100755 diff --git a/server/Kernel/Classes/DB.php b/server/Kernel/Classes/DB.php old mode 100644 new mode 100755 diff --git a/server/Kernel/Classes/Router.php b/server/Kernel/Classes/Router.php old mode 100644 new mode 100755 diff --git a/server/Kernel/Entity/Session.php b/server/Kernel/Entity/Session.php old mode 100644 new mode 100755 diff --git a/server/Kernel/Entity/User.php b/server/Kernel/Entity/User.php old mode 100644 new mode 100755 diff --git a/server/Kernel/load.php b/server/Kernel/load.php old mode 100644 new mode 100755 diff --git a/server/config.php b/server/config.php old mode 100644 new mode 100755 diff --git a/server/index.php b/server/index.php old mode 100644 new mode 100755 diff --git a/server/libs/DataContain.php b/server/libs/DataContain.php old mode 100644 new mode 100755 diff --git a/server/libs/DataStorage.php b/server/libs/DataStorage.php old mode 100644 new mode 100755 diff --git a/server/libs/utils.php b/server/libs/utils.php old mode 100644 new mode 100755 index 445c587..2891dd4 --- a/server/libs/utils.php +++ b/server/libs/utils.php @@ -1,15 +1,5 @@ $data - ]; - - @header('Content-Type: application/json'); - - return json_encode($response); -} - function app() { global $app; @@ -28,11 +18,26 @@ return date("Y-m-d H:i:s"); } -function error(String $class, String $errtext): Array { - return [ +function error_response(String $class, String $errtext) :Array { + return response(false, [ "error" => [ "class" => ucfirst($class), "text" => $errtext ] - ]; + ]); +} + +function success_response(Array $data) :Array { + return response(true, [ + "data" => $data + ]); +} + +function response(bool $status, Array $body = []) :Array { + @header('Content-Type: application/json'); + + return json_encode([ + "status" => $status, + "response" => $resp + ]); } \ No newline at end of file