54 lines
1.4 KiB
PHP
Executable File
54 lines
1.4 KiB
PHP
Executable File
<?php
|
|
//
|
|
//declare(strict_types=1);
|
|
///**
|
|
// * This file is part of the youyao/admin-api.
|
|
// *
|
|
// * (c) youyao <info@nuancebiotech.cn>
|
|
// * This source file is subject to the license under the project that is bundled.
|
|
// */
|
|
//namespace App\Kernel\Jwt;
|
|
//
|
|
//use App\Model\User;
|
|
//use Firebase\JWT\JWT as JwtSdk;
|
|
//use Hyperf\Contract\ConfigInterface;
|
|
//use Hyperf\Di\Annotation\Inject;
|
|
//use Youyao\Framework\Logger\LoggerApp;
|
|
//
|
|
//class Jwt
|
|
//{
|
|
// /**
|
|
// * @Inject
|
|
// * @var ConfigInterface
|
|
// */
|
|
// private $config;
|
|
//
|
|
// public function generate(User $user) # 数据表
|
|
// {
|
|
// $payload = [
|
|
// 'iss' => 'youyao-management',
|
|
// 'aud' => 'youyao-employees',
|
|
// 'iat' => time(),
|
|
// 'exp' => time() + $this->config->get('jwt.token_expires'),
|
|
// 'nbf' => time(),
|
|
// 'sub' => $user->getAttribute('id'),
|
|
// ];
|
|
// try {
|
|
// return JwtSdk::encode($payload, $this->config->get('jwt.key'));
|
|
// } catch (\Exception $e) {
|
|
// LoggerApp::error($e->getMessage(), $e->getTrace());
|
|
// return false;
|
|
// }
|
|
// }
|
|
//
|
|
// public function decode(string $token)
|
|
// {
|
|
// try {
|
|
// return (array) JwtSdk::decode($token, $this->config->get('jwt.key'), ['HS256']);
|
|
// } catch (\Exception $e) {
|
|
// LoggerApp::error($e->getMessage(), $e->getTrace());
|
|
// return false;
|
|
// }
|
|
// }
|
|
//}
|