Advertisement
razituli

Untitled

Jan 26th, 2022
857
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public function validationJWT($request)
  2.     {
  3.         $jwt = request()->header('Authorization');
  4.         $jwt = str_replace('Bearer ', '', $jwt);
  5.         $fcm = $request->header('fcm');
  6.  
  7.         try {
  8.             $data = JWT::decode($jwt, $this->key, array('HS256'));
  9.             return [
  10.                 "expired" => $this->JWT_EXPIRED,
  11.                 "jwt" => $jwt,
  12.                 "data" => (array)$data
  13.             ];
  14.         } catch (ExpiredException $ex) {
  15.             $data = $this->auth($fcm);
  16.             $payload = array(
  17.                 "id" => $data['data']['id_store'],
  18.                 "owner_name" => $data['data']['owner_name'],
  19.                 "store_name" => $data['data']['store_name'],
  20.                 "exp" => (round(microtime(true) * 1000) + ($this->TIME_EXPIRE * 60000))
  21.             );
  22.             $jwt = JWT::encode($payload, $this->key);
  23.             return [
  24.                 "expired" => !$this->JWT_EXPIRED,
  25.                 "data" => $payload,
  26.                 "jwt" => $jwt
  27.             ];
  28.         }
  29.     }
  30.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement