mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 15:57:50 +08:00
fix : first finish
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Common\Interface\JwtInterface;
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Middleware\Token\AbstractTokenMiddleware;
|
||||
use Hyperf\Context\Context;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
use function Hyperf\Support\env;
|
||||
@@ -29,4 +30,13 @@ final class AdminTokenMiddleware extends AbstractTokenMiddleware
|
||||
|
||||
if ($audience !== env('APP_NAME') .'_admin') throw new ErrException('token错误',ResultCode::JWT_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UnencryptedToken $token
|
||||
* @return void
|
||||
*/
|
||||
public function setContext(UnencryptedToken $token): void
|
||||
{
|
||||
Context::set('current_admin_id',(int)$token->claims()?->get(RegisteredClaims::ID) ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user