Ejemplo n.º 1
1
 /**
  * Decode token request header
  *
  * @return object
  */
 public static function getToken()
 {
     $jwt = \JWTAuth::getToken();
     if (!$jwt) {
         return null;
     }
     return \JWTAuth::decode($jwt)->get();
 }
 public function testToken()
 {
     $app = app();
     $config = $app->config;
     $user = Config::get("jwt::user");
     $identifier = Config::get("jwt::identifier");
     $customer = Customer::whereEmail('*****@*****.**')->first();
     $token = JWTAuth::fromUser($customer);
     $subject = JWTAuth::getSubject($token);
     // SOS! returns Customer->id === 1
     $this->assertEquals($customer->id, $subject);
     $claims = new stdClass();
     $claims->currency_id = 3;
     $claims->language_id = 1;
     $token = JWTAuth::encode(1, array('currency_id' => 3, 'language_id' => 1));
     $decoded = JWTAuth::decode($token->get());
     /********************** Prints ****************************/
     /*
     * Tymon\JWTAuth\Payload Object
                                (
                                    [value:protected] => Array
                                        (
                                            [currency_id] => 3
                                            [language_id] => 1
                                            [iss] => http://localhost
                                            [sub] => 1
                                            [iat] => 1417101103
                                            [exp] => 1417187503
                                        )
     
                                )
     */
 }