Update BaseApiController

This commit is contained in:
Daniel Supernault 2018-12-09 16:02:01 -07:00
parent 65cfbc428f
commit e1449b119a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -47,7 +47,7 @@ class BaseApiController extends Controller
$resource = new Fractal\Resource\Item($notification, new NotificationTransformer()); $resource = new Fractal\Resource\Item($notification, new NotificationTransformer());
$res = $this->fractal->createData($resource)->toArray(); $res = $this->fractal->createData($resource)->toArray();
return response()->json($res, 200, [], JSON_PRETTY_PRINT); return response()->json($res);
} }
public function accounts(Request $request, $id) public function accounts(Request $request, $id)
@ -56,7 +56,7 @@ class BaseApiController extends Controller
$resource = new Fractal\Resource\Item($profile, new AccountTransformer()); $resource = new Fractal\Resource\Item($profile, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray(); $res = $this->fractal->createData($resource)->toArray();
return response()->json($res, 200, [], JSON_PRETTY_PRINT); return response()->json($res);
} }
public function accountFollowers(Request $request, $id) public function accountFollowers(Request $request, $id)
@ -66,7 +66,7 @@ class BaseApiController extends Controller
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer()); $resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray(); $res = $this->fractal->createData($resource)->toArray();
return response()->json($res, 200, [], JSON_PRETTY_PRINT); return response()->json($res);
} }
public function accountFollowing(Request $request, $id) public function accountFollowing(Request $request, $id)
@ -76,7 +76,7 @@ class BaseApiController extends Controller
$resource = new Fractal\Resource\Collection($following, new AccountTransformer()); $resource = new Fractal\Resource\Collection($following, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray(); $res = $this->fractal->createData($resource)->toArray();
return response()->json($res, 200, [], JSON_PRETTY_PRINT); return response()->json($res);
} }
public function accountStatuses(Request $request, $id) public function accountStatuses(Request $request, $id)
@ -92,7 +92,7 @@ class BaseApiController extends Controller
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer()); $resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
$res = $this->fractal->createData($resource)->toArray(); $res = $this->fractal->createData($resource)->toArray();
return response()->json($res, 200, [], JSON_PRETTY_PRINT); return response()->json($res);
} }
public function followSuggestions(Request $request) public function followSuggestions(Request $request)
@ -140,13 +140,13 @@ class BaseApiController extends Controller
]); ]);
} }
public function showTempMedia(Request $request, $profileId, $mediaId) public function showTempMedia(Request $request, int $profileId, $mediaId)
{ {
if (!$request->hasValidSignature()) { if (!$request->hasValidSignature()) {
abort(401); abort(401);
} }
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
if($profile->id !== (int) $profileId) { if($profile->id !== $profileId) {
abort(403); abort(403);
} }
$media = Media::whereProfileId($profile->id)->findOrFail($mediaId); $media = Media::whereProfileId($profile->id)->findOrFail($mediaId);
@ -240,4 +240,13 @@ class BaseApiController extends Controller
return response()->json($res); return response()->json($res);
} }
public function verifyCredentials(Request $request)
{
$profile = Auth::user()->profile;
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
}
} }