コード例 #1
0
ファイル: CekMiddleware.php プロジェクト: tofa17/posmikro
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!empty($request->input('x-auth'))) {
         $access_token = $request->input('x-auth');
     } else {
         $access_token = $request->header('x-auth');
     }
     $cek_token = Key::where('key', $access_token)->first();
     if (!$access_token) {
         $response['error'][] = ['status' => false, 'message' => "An access token is required to request this resource.", 'required' => "x-auth", 'code' => 402];
         return response()->json($response, 402);
     }
     if (is_null($cek_token)) {
         $response['error'][] = ['status' => false, 'message' => "This token x-auth unauthorized", 'code' => 401];
         return response()->json($response, 401);
     }
     return $next($request);
 }
コード例 #2
0
ファイル: KeyController.php プロジェクト: tofa17/posmikro
 public function deleteKey($id)
 {
     if (empty(',')) {
         $key = Key::find($id);
         if (is_null($key)) {
             return $this->notFound();
         }
         $key = Key::destroy($id);
         if ($key) {
             return $this->httpOk();
         }
     } else {
         $key = Key::find(explode(',', $id));
         if (is_null($key)) {
             return $this->httpNotFound();
         }
         $key = Key::destroy(explode(',', $id));
         if ($key) {
             return $this->httpOk();
         }
     }
 }