# 单点检测 $this->verifySignLogin($admin->id, $params['mobile'], $token); /** * @param $uid * @param $token */ private function verifySignLogin($uid, $mobile ,$token) { # 获取当前登陆ip $request = Request::instance(); $ip = $request->ip(); $redis = Cache::store('redis')->handler(); $redis->select(1); $info = $redis->hGetAll($uid . '-' . $mobile); if (!$info) { $redis->hSet($uid . '-' . $mobile, 'token', $token); $redis->hSet($uid . '-' . $mobile, 'ip', $ip); } else { if ($info['ip'] != $ip) { # 添加黑名单 JWTAuth::invalidate($info['token']); # 重置缓存 $redis->hSet($uid . '-' . $mobile, 'token', $token); $redis->hSet($uid . '-' . $mobile, 'ip', $ip); }else{ $redis->hSet($uid . '-' . $mobile, 'token', $token); } } }
标签:单点,uid,登录,mobile,ip,redis,token,hSet From: https://www.cnblogs.com/G921123/p/17815584.html