feat: jwt
This commit is contained in:
@@ -23,6 +23,12 @@ class JwtCrypto implements CryptoInterface
|
||||
*/
|
||||
public string $data = '';
|
||||
|
||||
/**
|
||||
* 登录类型
|
||||
* @var string
|
||||
*/
|
||||
public string $type = '';
|
||||
|
||||
/**
|
||||
* 加密 key
|
||||
* @var string
|
||||
@@ -41,7 +47,6 @@ class JwtCrypto implements CryptoInterface
|
||||
public function __construct()
|
||||
{
|
||||
$this->key = config('system.jwt_key');
|
||||
$this->expire = (int)config('system.jwt_expire');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,6 +55,16 @@ class JwtCrypto implements CryptoInterface
|
||||
*/
|
||||
public function encrypt(): string
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 'admin-jwt':
|
||||
$this->expire = (int)config('system.admin_jwt_expire');
|
||||
break;
|
||||
default:
|
||||
case 'jwt':
|
||||
$this->expire = (int)config('system.jwt_expire');
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
$time = time();
|
||||
$payload = [
|
||||
|
||||
Reference in New Issue
Block a user