Created
September 22, 2019 16:05
-
-
Save ahmadwaliesipick/a0307b5df19f56bac505ee19385ef488 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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