コード例 #1
0
ファイル: DeviceProvider.php プロジェクト: imjerrybao/PushApp
 public function authenticate(Request $request, Route $route)
 {
     $token = $request->header('X-Token');
     if (!Device::attempt($token)) {
         throw new UnauthorizedHttpException('Unable to authenticate with supplied username and password.');
     }
 }
コード例 #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Request::is('api/auth/bind') && !Request::is('api/auth/check')) {
         $token = $request->header('X-Token');
         if (!Device::attempt($token)) {
             return Response::error(Lang::get('errors.unauthorized'), 401);
         }
     }
     return $next($request);
 }