Merge branch 'feature-BOX一期' of http://47.99.132.106:10081/wulin/qiuguo-iot into feature-BOX一期

This commit is contained in:
wulin 2023-10-20 20:46:40 +08:00
commit ac23efe3a0

View File

@ -46,19 +46,20 @@ public class AuthFilter implements GlobalFilter, Ordered {
if (ObjectUtils.isEmpty(api_token) || ObjectUtils.isEmpty(api_type)) { if (ObjectUtils.isEmpty(api_token) || ObjectUtils.isEmpty(api_type)) {
return Mono.error(new RuntimeException("未登录")); return Mono.error(new RuntimeException("未登录"));
} }
String key = RedisConstans.IOT_TOKEN.concat(api_token); return chain.filter(exchange);
return reactiveRedisTemplate.getExpire(key).map(Duration::getSeconds).flatMap(ttl -> { // String key = RedisConstans.IOT_TOKEN.concat(api_token);
if (ttl == -1) { // return reactiveRedisTemplate.getExpire(key).map(Duration::getSeconds).flatMap(ttl -> {
// 用户没登陆 // if (ttl == -1) {
return Mono.error(new RuntimeException("未登录")); // // 用户没登陆
} else if (ttl <= 3600) { // return Mono.error(new RuntimeException("未登录"));
// token 将要失效 // } else if (ttl <= 3600) {
return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange)); // // token 将要失效
} else { // return reactiveRedisTemplate.expire(key, Duration.ofDays(7)).then(chain.filter(exchange));
// 正常登录 // } else {
return chain.filter(exchange); // // 正常登录
} // return chain.filter(exchange);
}); // }
// });
} }