代码拉取完成,页面将自动刷新
同步操作将从 Thans/jwt-auth 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
namespace thans\jwt;
use thans\jwt\exception\BadMethodCallException;
use thans\jwt\parser\Parser;
use thans\jwt\exception\JWTException;
class JWT
{
protected $manager;
protected $parser;
protected $token;
public function parser()
{
return $this->parser;
}
public function __construct(Manager $manager, Parser $parser)
{
$this->manager = $manager;
$this->parser = $parser;
}
public function createToken($customerClaim = [])
{
return $this->manager->encode($customerClaim)->get();
}
public function parseToken()
{
if (! $token = $this->parser->parseToken()) {
throw new JWTException('No token is this request.');
}
$this->setToken($token);
return $this;
}
public function getToken()
{
if ($this->token === null) {
try {
$this->parseToken();
} catch (JWTException $e) {
$this->token = null;
}
}
return $this->token;
}
public function setToken($token)
{
$this->token = $token instanceof Token ? $token : new Token($token);
return $this;
}
public function requireToken()
{
$this->getToken();
if (! $this->token) {
throw new JWTException('Must have token');
}
}
/**
* 获取Payload
* @return mixed
* @throws JWTException
* @throws exception\TokenBlacklistException
*/
public function getPayload()
{
$this->requireToken();
return $this->manager->decode($this->token);
}
/**
* 刷新Token
* @return mixed
* @throws JWTException
*/
public function refresh()
{
$this->parseToken();
return $this->manager->refresh($this->token)->get();
}
public function __call($method, $parameters)
{
if (method_exists($this->manager, $method)) {
return call_user_func_array([$this->manager, $method], $parameters);
}
throw new BadMethodCallException("Method [$method] does not exist.");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。