12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace app\http\middleware;
- use app\hander\HelpHander;
- use think\Db;
- class Auth
- {
- public function handle($request, \Closure $next)
- {
- $token = $request->param('token');
- $userId = $request->param('userId');
- if(empty($token) || empty($userId)){
- HelpHander::error('登录信息已失效',100200);
- }
- $tokeninfo = Db::name('token')
- ->where('code',$token)
- ->where('user_id',$userId)
- ->find();
- if(!$tokeninfo){
- HelpHander::error('登录信息已失效',100200);
- }
- // 检查用户是否被禁用
- $user = Db::name('user')->where('id',$userId)->find();
- if(!$user || $user['enable'] == 0 || $user['del'] == 1){
- HelpHander::error('登录信息已失效',100200);
- }
- return $next($request);
- }
- }
|