new files
This commit is contained in:
54
pro_v3.5.1/app/http/middleware/out/AuthTokenMiddleware.php
Normal file
54
pro_v3.5.1/app/http/middleware/out/AuthTokenMiddleware.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\http\middleware\out;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\out\OutAccountServices;
|
||||
use app\services\out\OutInterfaceServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Class AuthTokenMiddleware
|
||||
* @package app\http\middleware\out
|
||||
*/
|
||||
class AuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
/** @var OutAccountServices $services */
|
||||
$services = app()->make(OutAccountServices::class);
|
||||
$outInfo = $services->parseToken($token);
|
||||
|
||||
$request->outId = (int)$outInfo['out_id'];
|
||||
|
||||
$request->outInfo = $outInfo;
|
||||
|
||||
/** @var OutInterfaceServices $outInterfaceServices */
|
||||
$outInterfaceServices = app()->make(OutInterfaceServices::class);
|
||||
$outInterfaceServices->verifyAuth($request);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user