本文整理汇总了PHP中Tymon\JWTAuth\Facades\JWTAuth::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP JWTAuth::encode方法的具体用法?PHP JWTAuth::encode怎么用?PHP JWTAuth::encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tymon\JWTAuth\Facades\JWTAuth
的用法示例。
在下文中一共展示了JWTAuth::encode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auth
/**
* Display a listing of the resource.
*
* @return Response
*/
public function auth(Request $request)
{
$userData = $this->currentUser->payloadInfo;
$payload = JWTFactory::make($userData);
$data = JWTAuth::encode($payload);
$redirectPath = $request->cookie('referer');
return Redirect::to($redirectPath, 303)->withCookie('x-access-token', $data->get())->withCookie('serverUID', $userData['id']);
}
示例2: auth
/**
* Display a listing of the resource.
*
* @return Response
*/
public function auth(Request $request)
{
$customClaims = ['id' => '55dc13391846c68a1ad56daa', 'email' => 'admin@admin', 'role' => 'ADMIN', 'iat' => 1440615292];
$payload = JWTFactory::make($customClaims);
$data = JWTAuth::encode($payload);
$redirectPath = $request->cookie('referer');
return Redirect::to($redirectPath, 303)->withCookie('x-access-token', $data->get())->withCookie('serverUID', '55dc13391846c68a1ad56daa');
}