require 'control.php'; require 'class.php'; $app = new Slim\Slim(); // return HTTP 200 for HTTP OPTIONS requests $app->map('/:x+', function ($x) { http_response_code(200); })->via('OPTIONS'); // throw new Exception("Invalid Credentials.", 401); // Registration $app->post('/register', function () use($app) { $request = (array) json_decode($app->request->getBody()); $action = new Identity(); $action->register($request); $insert = new Request(); $insert->insert($action->sql); $insert->query($action->get($insert)); $user = $insert->response; $user = $user[0]; $user['fname'] = decode5t($user['fname']); $user['lname'] = decode5t($user['lname']); $auth = new AUTH(); $auth->set($_SERVER['HTTP_ORIGIN'], $request['email']); $response['Ident'] = $user; $response['Auth'] = $auth->token; $tok = new AUTHTOKEN(); $tok->get(); $jwt = JWT::encode($response, $tok->response); echo json_encode($jwt); }); // Login $app->post('/login', function () use($app) {