12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm
- * User:林志杰
- * Email:[email protected]
- * Motto:纵有疾风起,人生不言弃!
- * Time:2020/1/4 0:15
- */
- declare (strict_types=1);
- namespace app\admin\middleware;
- class Auth
- {
- public function handle($request, \Closure $next)
- {
- // dump($request->pathinfo());
- // 前置中间件
- if (empty(session(config('admin.session_admin'))) && !preg_match('/login/',$request->pathinfo())) {
- return redirect((string) url('login/index'));
- }
- $response = $next($request);
- // if (empty(session(config('admin.session_admin'))) && $request->controller() !== 'Login') {
- // return redirect((string)url('login/index'));
- // }
- return $response;
- // 后置中间件
- }
- /**
- * 中间件结束调度
- * @param \think\Response $response
- */
- public function end(\think\Response $response)
- {
- }
- }
|