Used CKEditor for being able to edit the post body. Added the ability to make a post and send it to the backend. Formatted post on backend by moving images into respective directory with the post name and unique ID. Showed message if errored or succeeded.
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ class middleware
|
||||
* Constructor for middleware
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
function __construct(App $app)
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$this->baseMiddleware($app);
|
||||
$this->sameSiteConfig($app);
|
||||
@@ -40,7 +40,7 @@ class middleware
|
||||
* Base middleware
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
function baseMiddleware(App $app): void
|
||||
public function baseMiddleware(App $app): void
|
||||
{
|
||||
$app->addBodyParsingMiddleware();
|
||||
$app->addRoutingMiddleware();
|
||||
@@ -50,7 +50,7 @@ class middleware
|
||||
* SameSite Cookie Configuration
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
function sameSiteConfig(App $app): void
|
||||
public function sameSiteConfig(App $app): void
|
||||
{
|
||||
$ssConfig = new SameSiteCookieConfiguration(["same_site" => "strict"]);
|
||||
$app->add(new SameSiteCookieMiddleware($ssConfig));
|
||||
@@ -60,7 +60,7 @@ class middleware
|
||||
* Return all responses as JSON
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
function returnAsJSON(App $app): void
|
||||
public function returnAsJSON(App $app): void
|
||||
{
|
||||
$app->add(function ($request, $handler)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ class middleware
|
||||
* JWT Authentication
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
function jwtAuth(App $app): void
|
||||
public function jwtAuth(App $app): void
|
||||
{
|
||||
$jwtSecret = getSecretKey();
|
||||
$app->add(new JwtAuthentication([
|
||||
@@ -90,14 +90,18 @@ class middleware
|
||||
"error" => function ($response)
|
||||
{
|
||||
session_destroy();
|
||||
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
||||
"Unauthorized, please provide a valid token")));
|
||||
$response->getBody()->write(json_encode(array("status" => "401", "message" =>
|
||||
"Unauthorized, please provide a valid token")));
|
||||
return $response->withStatus(401);
|
||||
}
|
||||
]));
|
||||
}
|
||||
|
||||
function errorHandling(App $app): void
|
||||
/**
|
||||
* Error handling
|
||||
* @param App $app - Slim App
|
||||
*/
|
||||
public function errorHandling(App $app): void
|
||||
{
|
||||
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user