fix api auth problem
This commit is contained in:
parent
7700bd6683
commit
6d2f705b40
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user