本文整理匯總了PHP中Authenticate::reissueToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authenticate::reissueToken方法的具體用法?PHP Authenticate::reissueToken怎麽用?PHP Authenticate::reissueToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Authenticate
的用法示例。
在下文中一共展示了Authenticate::reissueToken方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: base64_decode
require 'autoload.php';
/*
* Configure Slim app
* 1. Create Slim app
* 2. Add JWT middleware for json web token authentication
* 3. Allow CORS request so itl will accept calls from other domains
*/
// 1
$app = new \Slim\Slim();
// 2
$app->add(new \Slim\Middleware\JwtAuthentication(["secret" => base64_decode(JWT_SECRET), "path" => ["/api"], "callback" => function ($options) use($app) {
$app->oldJwt = $options["decoded"];
$decodedData = (array) $app->oldJwt->data;
$user_id = $decodedData['user_id'];
$user_name = $decodedData['user_name'];
$app->newToken = Authenticate::reissueToken($user_id, $user_name);
// $options["decoded"];
}]));
// 3
$app->add(new \CorsSlim\CorsSlim(array("origin" => "*", "allowCredentials" => True)));
/*
* API ROUTES
*/
// get all users
$app->get('/api/users', function () use($app, $database) {
$resultArr['token'] = $app->newToken;
$resultArr['result'] = UsersAPI::get($database);
echo json_encode($resultArr);
});
// add new user
$app->post('/api/users', function () use($app, $database) {