Well, I did make it work.
settings.blade.php
Show API Link only to developers by adding another condition, so that only devs can generate tokens.
<!-- API Link -->
@if (Spark::usesApi() && Spark::developer(Auth::user()->email))
<li role="presentation">
<a href="#api" aria-controls="api" role="tab" data-toggle="tab">
<i class="fa fa-fw fa-btn fa-cubes"></i>API
</a>
</li>
@endif
And in routes/api.php
add the 'dev' middleware, so that only developers can access API.
Route::group([
'prefix' => 'api',
'middleware' => ['auth:api', 'dev']
], function () {
//
Route::get('/test', function() {
return 'Hello';
});
});
Although the API links is not shown in frontend the routes for generating tokens are still accessible. Let's say a user still painstakingly POSTs the right data to /settings/api/token to generate a token, he won't be able to get any data from API because of the 'dev' middleware.