单点登录
# 单点检测 $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); } } }
作者地址:https://www.cnblogs.com/G921123/
创作也有乐趣 知识分享 转载注明出处 相互理解 谢谢!
创作也有乐趣 知识分享 转载注明出处 相互理解 谢谢!