Skip to content

Commit

Permalink
Merge branch 'release/1.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
aronnebrivio committed Oct 13, 2021
2 parents 793174d + 16e9256 commit 0d04377
Show file tree
Hide file tree
Showing 17 changed files with 676 additions and 417 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function new(Request $request)
'password' => 'required|string|min:6',
'first_name' => 'filled|string',
'last_name' => 'filled|string',
'picture' => 'filled|url',
]);

$data = $request->all();
Expand Down Expand Up @@ -73,6 +74,7 @@ public function update(Request $request, $id)
'first_name' => 'filled|string',
'last_name' => 'filled|string',
'password' => 'filled|string|min:6',
'picture' => 'filled|url',
]);

if ($this->emailExists($request->input('email'))) {
Expand Down
38 changes: 38 additions & 0 deletions app/Http/Middleware/CorsMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Http\Middleware;

use Closure;

class CorsMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$headers = [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE',
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Max-Age' => '86400',
'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Request-With',
];

if ($request->isMethod('OPTIONS')) {
return response()->json('{"method":"OPTIONS"}', 200, $headers);
}

$response = $next($request);
foreach ($headers as $key => $value) {
$response->header($key, $value);
}

return $response;
}
}
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
'email',
'first_name',
'last_name',
'picture',
];

/**
Expand Down
8 changes: 4 additions & 4 deletions app/Policies/CommentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class CommentPolicy
/**
* Determine if the given comment can be updated by the user.
*
* @param User $user
* @param Comment $comment
* @param User $user
* @param Comment $comment
*
* @return Response
*/
Expand All @@ -28,8 +28,8 @@ public function update(User $user, Comment $comment): Response
/**
* Determine if the given comment can be deleted by the user.
*
* @param User $user
* @param Comment $comment
* @param User $user
* @param Comment $comment
*
* @return Response
*/
Expand Down
1 change: 1 addition & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

$app->middleware([
App\Http\Middleware\ParseMultipartFormDataInputForNonPostRequestsMiddleware::class,
App\Http\Middleware\CorsMiddleware::class,
]);

$app->routeMiddleware([
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lumen",
"api"
],
"version": "1.1.6",
"version": "1.1.7",
"license": "MIT",
"type": "project",
"require": {
Expand Down Expand Up @@ -52,7 +52,8 @@
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
"optimize-autoloader": true,
"platform-check": false
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
Loading

0 comments on commit 0d04377

Please sign in to comment.