diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..a1f75dd --- /dev/null +++ b/.eslintrc @@ -0,0 +1,70 @@ +{ + "parserOptions": { + "ecmaVersion": 7, + "sourceType": "module", + "ecmaFeatures": {} + }, + "rules": { + "constructor-super": 2, + "for-direction": 2, + "getter-return": 2, + "no-case-declarations": 2, + "no-class-assign": 2, + "no-compare-neg-zero": 2, + "no-cond-assign": 2, + "no-console": 1, + "no-const-assign": 2, + "no-constant-condition": 2, + "no-control-regex": 1, + "no-debugger": 2, + "no-delete-var": 2, + "no-dupe-args": 2, + "no-dupe-class-members": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-empty": 2, + "no-empty-character-class": 2, + "no-empty-pattern": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-semi": 2, + "no-fallthrough": 2, + "no-func-assign": 2, + "no-global-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-mixed-spaces-and-tabs": 2, + "no-new-symbol": 2, + "no-obj-calls": 2, + "no-octal": 2, + "no-redeclare": 2, + "no-regex-spaces": 2, + "no-self-assign": 2, + "no-sparse-arrays": 2, + "no-this-before-super": 2, + "no-undef": 2, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "no-unsafe-finally": 2, + "no-unsafe-negation": 2, + "no-unused-labels": 2, + "no-unused-vars": 2, + "no-useless-escape": 1, + "require-yield": 2, + "use-isnan": 2, + "valid-typeof": 2, + "no-duplicate-imports": 2 + }, + "env": { + "node": true, + "browser": true, + "es6": true + }, + "globals": { + "_": false, + "hljs": false, + "Sortable": false, + "Prism": false + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4264576..85257c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +src/node_modules/ .sass-cache/ .cache/ .nova/ diff --git a/brain/controller/APIControl.inc.php b/brain/controller/APIControl.inc.php index caad565..c55e7bd 100644 --- a/brain/controller/APIControl.inc.php +++ b/brain/controller/APIControl.inc.php @@ -6,7 +6,23 @@ use Psr\Http\Message\ServerRequestInterface; class APIControl { - public static function start( + public static function get( + ServerRequestInterface $request, + ResponseInterface $response, + array $args + ): ResponseInterface { + switch (isset($args["third"]) ? $args["third"] : "none") { + case "status": + $result = Auth::status(); + break; + default: + break; + } + + $response->getBody()->write(json_encode($result)); + return $response->withHeader("Content-Type", "application/json"); + } + public static function post( ServerRequestInterface $request, ResponseInterface $response, array $args @@ -24,7 +40,6 @@ class APIControl switch (isset($args["third"]) ? $args["third"] : "none") { case "login": $result = Auth::login($body); - break; case "logout": $result = Auth::logout($body); @@ -38,7 +53,6 @@ class APIControl } $response->getBody()->write(json_encode($result)); - return $response->withHeader("Content-Type", "application/json"); } } diff --git a/brain/controller/RouteControl.inc.php b/brain/controller/RouteControl.inc.php index 8b80ec8..b207b1f 100644 --- a/brain/controller/RouteControl.inc.php +++ b/brain/controller/RouteControl.inc.php @@ -17,6 +17,9 @@ class RouteControl case "dashboard": return DashControl::start($request, $response, $args); break; + case "api": + return APIControl::get($request, $response, $args); + break; default: return IndexControl::start($request, $response, $args); break; @@ -30,7 +33,7 @@ class RouteControl ): ResponseInterface { switch (isset($args["first"]) ? $args["first"] : "index") { case "api": - return APIControl::start($request, $response, $args); + return APIControl::post($request, $response, $args); break; default: //echo "YES"; diff --git a/brain/data/Auth.inc.php b/brain/data/Auth.inc.php index 38c4851..8dda0f0 100644 --- a/brain/data/Auth.inc.php +++ b/brain/data/Auth.inc.php @@ -19,6 +19,25 @@ class Auth //return $this->secret; } + public static function status() + { + $result = []; + if (Session::active()) { + $result = [ + "message" => "Authorized", + "type" => "apiUseAuthorized", + "token" => Session::get("token"), + ]; + } else { + $result = [ + "message" => "Not Authorized", + "type" => "apiUseNotAuthorized", + ]; + } + + return $result; + } + public static function login($who) { //grab member list @@ -47,19 +66,19 @@ class Auth $result = [ "message" => "Welcome back", - "type" => "TASK_LOGIN", + "type" => "requestGood", ]; } else { $result = [ "message" => "Check your password, sport", - "type" => "TASK_LOGIN", + "type" => "requestLame", ]; } } else { //if name is not found $result = [ "message" => "Need to see some id, champ", - "type" => "TASK_LOGIN", + "type" => "requestLame", ]; } return $result; diff --git a/brain/data/Settings.inc.php b/brain/data/Settings.inc.php index d540bce..0ff27c1 100644 --- a/brain/data/Settings.inc.php +++ b/brain/data/Settings.inc.php @@ -17,7 +17,7 @@ class Settings ); } - public function getFolks($key) + public function getFolks($key = null) { if (isset($key)) { $member = Session::get("member"); diff --git a/brain/views/dash/_frame.twig b/brain/views/dash/_frame.twig index 8605cac..47cf39d 100644 --- a/brain/views/dash/_frame.twig +++ b/brain/views/dash/_frame.twig @@ -13,14 +13,15 @@