Initial commit: queue workspace
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?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\admin;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\admin\AdminAuthServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 后台登陆验证中间件
|
||||
* Class AdminAuthTokenMiddleware
|
||||
* @package app\http\middleware\admin
|
||||
*/
|
||||
class AdminAuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
|
||||
/** @var AdminAuthServices $service */
|
||||
$service = app()->make(AdminAuthServices::class);
|
||||
$adminInfo = $service->parseToken($token);
|
||||
|
||||
$request->isAdminLogin = !is_null($adminInfo);
|
||||
$request->adminId = $adminInfo['id'];
|
||||
$request->adminInfo = $adminInfo;
|
||||
$request->adminType = $adminInfo['admin_type'];
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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\admin;
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\SystemRoleServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\utils\ApiErrorCode;
|
||||
|
||||
/**
|
||||
* 权限规则验证
|
||||
* Class AdminCkeckRoleMiddleware
|
||||
* @package app\http\middleware
|
||||
*/
|
||||
class AdminCkeckRoleMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (!$request->adminId() || !$request->adminInfo())
|
||||
throw new AuthException(ApiErrorCode::ERR_ADMINID_VOID);
|
||||
// $data = [
|
||||
// 'adminapi/channel/merchant/verify'
|
||||
// ];
|
||||
// $noData = [
|
||||
// 'config/storage',
|
||||
// 'print/form',
|
||||
// 'edit_new_build/routine'
|
||||
// ];
|
||||
// $rule = trim(strtolower($request->rule()->getRule()));
|
||||
// foreach ($noData as $tiem){
|
||||
// if (strpos($rule, $tiem) !== false) {
|
||||
// return app('json')->fail('暂无权限');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if ($request->adminId() != 1 && in_array($request->method(), ['POST', 'PUT', 'DELETE']) && !in_array($rule, $data)){
|
||||
// return app('json')->fail('暂无权限');
|
||||
// }
|
||||
if ($request->adminInfo()['level']) {
|
||||
/** @var SystemRoleServices $systemRoleService */
|
||||
$systemRoleService = app()->make(SystemRoleServices::class);
|
||||
$systemRoleService->verifiAuth($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
41
pro_v3.5.1/app/http/middleware/admin/AdminLogMiddleware.php
Normal file
41
pro_v3.5.1/app/http/middleware/admin/AdminLogMiddleware.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\admin;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\jobs\system\AdminLogJob;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 日志中間件
|
||||
* Class AdminLogMiddleware
|
||||
* @package app\http\middleware\admin
|
||||
*/
|
||||
class AdminLogMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$module = app('http')->getName();
|
||||
$rule = trim(strtolower($request->rule()->getRule()));
|
||||
//记录后台日志
|
||||
AdminLogJob::dispatch([$request->adminId(), $request->adminInfo()['account'], $module, $rule, $request->ip(), 'system']);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user