12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App\Http\Middleware;
- use App\Services\Auth\AuthService;
- use Closure;
- use Illuminate\Support\Facades\Auth;
- /**
- * 系统检查
- * Class SystemCheck
- * @package App\Http\Middleware
- * Auth Zhong
- * Date 2019/2/22
- */
- class SystemCheck
- {
- /**
- * @var AuthService
- */
- private $authService;
- /**
- * SystemCheck constructor.
- * @param AuthService $authService
- */
- public function __construct(AuthService $authService)
- {
- $this->authService = $authService;
- }
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if (config('aix.system.site.site.close_web') == 1 && !str_contains($request->route()->getPrefix(), 'admin')) {
- //网站暂时关闭
- $data=['message'=>config('aix.system.site.site.close_reason'),
- 'jump_url'=>config('app.url'),
- 'is_error'=>true,
- 'return_page_name'=>"首页",
- 'count_down'=>0
- ];
- return response()->view('app.show_message', $data);
- }
- if (config('aix.system.site_safety.ban_ip.filter_ip') == 1) {
- //过滤ip
- $ips=explode('|', config('aix.system.site_safety.ban_ip.filter_ip_address'));
- if (is_array($ips) && in_array($request->ip(), $ips)) {
- $data=['message'=>config('aix.system.site_safety.ban_ip.filter_ip_error'),
- 'jump_url'=>config('app.url'),
- 'is_error'=>true,
- 'return_page_name'=>"首页",
- 'count_down'=>0
- ];
- return response()->view('app.show_message', $data);
- }
- }
- if (Auth::guard('web-member')->check() && !str_contains($request->route()->getPrefix(), 'admin')) {
- //dd(Auth::guard('web-member')->user());
- if (Auth::guard('web-member')->user()->status == 0) {
- $this->authService->logout();
- $data=['message'=>"你的账号处于封禁状态, 请联系管理员进行解封后再操作",
- 'jump_url'=>config('app.url'),
- 'is_error'=>true,
- 'return_page_name'=>"首页",
- 'count_down'=>8
- ];
- return response()->view('app.show_message', $data);
- }
- }
- if (Auth::guard('web-company')->check() && !str_contains($request->route()->getPrefix(), 'admin')) {
- if (Auth::guard('web-company')->user()->user_status == 0) {
- $this->authService->logout();
- $data=['message'=>"你的账号处于封禁状态, 请联系管理员进行解封后再操作",
- 'jump_url'=>config('app.url'),
- 'is_error'=>true,
- 'return_page_name'=>"首页",
- 'count_down'=>8
- ];
- return response()->view('app.show_message', $data);
- }
- }
- return $next($request);
- }
- }
|