diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php index 08107a3e..879765a9 100644 --- a/app/Http/Controllers/Api/PirepController.php +++ b/app/Http/Controllers/Api/PirepController.php @@ -2,9 +2,9 @@ namespace App\Http\Controllers\Api; +use Auth; use Log; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; use App\Models\Acars; use App\Models\Pirep; diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index c5367ebb..4372493c 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use Auth; use Illuminate\Http\Request; use App\Http\Controllers\AppBaseController; @@ -30,7 +31,7 @@ class UserController extends AppBaseController public function index(Request $request) { UserResource::withoutWrapping(); - return new UserResource($request->user); + return new UserResource(Auth::user()); } /** diff --git a/app/Http/Middleware/ApiAuth.php b/app/Http/Middleware/ApiAuth.php index 4fcac986..8e411b28 100644 --- a/app/Http/Middleware/ApiAuth.php +++ b/app/Http/Middleware/ApiAuth.php @@ -38,7 +38,7 @@ class ApiAuth // Set the user to the request Auth::setUser($user); - //$request->merge(['user' => $user]); + $request->merge(['user' => $user]); $request->setUserResolver(function () use ($user) { return $user; }); diff --git a/tests/AcarsTest.php b/tests/AcarsTest.php index f0ecbe93..54b3c4a4 100644 --- a/tests/AcarsTest.php +++ b/tests/AcarsTest.php @@ -124,10 +124,13 @@ class AcarsTest extends TestCase { $uri = '/api/pireps/prefile'; $user = factory(App\Models\User::class)->create(); - $pirep = factory(App\Models\Pirep::class)->make(['id' => ''])->toArray(); + $pirep = factory(App\Models\Pirep::class)->make([ + 'id' => '', + 'user_id' => $user->id, + ])->toArray(); $response = $this->withHeaders($this->apiHeaders())->post($uri, $pirep); -// $response = $this->withHeaders($this->headers($user->api_key))->post($uri, $pirep); + #$response = $this->withHeaders($this->headers($user->api_key))->post($uri, $pirep); $response->assertStatus(201); $pirep = $response->json();