public static function getLoggedInUser() { if (!array_key_exists('userID', $_SESSION)) { return false; } return User::getById($_SESSION['userID']); }
} } catch (UserNotFoundException $e) { outputError($e->getMessage(), $e->getCode()); } }); $app->get('/auth/current', function () { $user = User::getLoggedInUser(); // print_r($user); if ($user) { outputJSON($user); } else { outputError('Not logged in', 100); } }); $app->get('/auth/logout', function () { User::logout(); outputJSON(array('status' => 'success')); }); $app->post('/upload/image', function () use($app) { // Setup file storage $file_storage = new \Upload\Storage\FileSystem("../assets/images"); $file = new Upload\File("file", $file_storage); $file->addValidations(array(new Upload\Validation\Mimetype(array('image/png', 'image/gif', 'image/jpeg', 'video/JPEG', 'video/jpeg2000')))); $file->setName(uniqid()); try { // Success! $file->upload(); header("Content-Type: text/html"); print json_encode(array("status" => "success", "filename" => $file->getName() . '.' . $file->getExtension())); exit; } catch (\Exception $e) {