feat: jwt

This commit is contained in:
2024-10-27 19:34:20 +08:00
parent 10037e11fd
commit a60c6ea29e
13 changed files with 697 additions and 8 deletions

View File

@@ -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 = [