コード例 #1
0
 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
                                        )
     
                                )
     */
 }