Skip to content

Instantly share code, notes, and snippets.

@ahmadwaliesipick
Created September 22, 2019 16:05
Show Gist options
  • Save ahmadwaliesipick/a0307b5df19f56bac505ee19385ef488 to your computer and use it in GitHub Desktop.
Save ahmadwaliesipick/a0307b5df19f56bac505ee19385ef488 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use App\User;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Dingo\Api\Routing\Helpers;
class CheckApiToken
{
use Helpers;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$request->hasHeader('Authorization') && $request->path() != 'api/auth/login' && $request->path() != 'api/auth/signup' && $request->path() != 'api/auth/forgotpassword'){
return $this->response->errorUnauthorized('Authorization Token Missing');
}
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment