first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\business\middleware;
|
||||
|
||||
use Closure;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
|
||||
class Auth
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
// 获取当前请求的控制器和方法
|
||||
$controller = $request->controller();
|
||||
$action = $request->action();
|
||||
|
||||
// 如果请求的控制器是 Supplier 且方法是 sendintention,则跳过验证
|
||||
if ($controller === 'Supplier' && $action === 'sendintention') {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// 执行登录验证逻辑
|
||||
if (!session('?user_id')) {
|
||||
// 未登录,返回错误或重定向到登录页面
|
||||
return redirect('login/index');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user